Latest version 0.1
Released 3 weeks ago
Initial release.
Perhaps you’re familiar with how most wikis have standardized, reusable sections, such as infoboxes at the top right of many Wikipedia articles. Wouldn’t it be cool to have similar templates in Kanka, where you can define standard blocks to invoke throughout your campaign with variable content? Well, this plugin acts as a building block to do just that in as few steps as possible! Check out the image at the bottom for the tl;dr, or read on for the detailed step-by-step!
<p>This is a template!</p>
<p>My name is <span id="name"></span>.</p>
<p>Welcome to <span id="location"></span>!</p>
In this (boring) example, the template consists of three paragraphs with some standard text, and two empty spans acting as placeholders (presumably for a name and a location).
Save, and your template is ready to use in as many places as you want.
In any entity, create an advanced mention to your template entity, wherever you want the template to go. (Advanced mentions can be enabled in your profile settings, under Appearance.) Switch to code view in the editor, and locate your mention code. Add the
field:attributes
parameter to it to transclude the character sheet rather than simply link to the entity, like so: [entity:12345|field:attributes]
.
Surround the mention code with an HTML element that will 1) tell the template where to go; 2) tell the plugin what to put in the template’s placeholders. Let’s look at an example first, then go over the details:
<span class="template-target hidden"> {"name": "Adam \"Shotgun\" Thompson", "location": "Paraiso"} [note:7362305|field:attributes<ins class="advanced-mention-name" data-name="Template #21"></ins>] </span>
class='orange'
with double quotes and mess things up).And... that’s about it, really. The plugin will create an element that has the structure of your HTML Template attribute, fill it with the values passed by its parent template-target element, and then replace the latter with the resulting HTML block.
All in all, the plugin only does a couple generic, one-size-fits-all operations, but you can build unlimited templates with it (subject to the HTML whitelist of course) and use them in all kinds of scenarios, like infoboxes, stat blocks or modular sections for your articles, creating variants and supplementing them with custom CSS! I would LOVE to see what you build with it!
Want to show appreciation for my plugins or request one-on-one CSS help? I accept tips on Ko-fi (no account needed):
Released 3 weeks ago
Initial release.