Sunday, February 25, 2018

TiddlyWiki - Templates

I recently finished running two campaigns: Daruna, which ended in an epic battle that brought things to a satisfying conclusion, and the Colony, which was... less good. As part of my post-campaign shutdown process, I take a look at the TiddlyWiki for each campaign to see if I can improve my GM notes and recordkeeping. As usual,  I find some new features and tricks that I roll back into my customized empty GM wiki. Today, I'm going to talk a bit about templates for TiddlyWiki.

There are two concepts I'll discuss today:

  • Template tiddlers are a way to reuse specific chunks of wikitext. 
  • Transclusion is the process of referencing one tiddler's content from within another tiddler.
Here's a concrete example using the markup text to show the title of a tiddler as a link (details here):

     <$link><$view field="title"></$view></$link>

Now, I use this markup in every tiddler I write because it makes it simple to open a transcluded tiddler. I also use a variety of header levels (indicated using ! or !! or !!! markup) for different tiddler types. The above is too much typing, so I made a set of templates named H1, H2, and H3 (which match the top three levels of HTML headers -- an easy mnemonic). Each has one line:

     H1: ! <$link><$view field="title"></$view></$link>
     H2: !! <$link><$view field="title"></$view></$link>
     H3: !!! <$link><$view field="title"></$view></$link>

Using normal transclusion markup, {{H1}} for example, is not very useful because it just inserts a level one header with a link to the H1 tiddler. If you use template transclusion though, the transcluded tiddler, H1, uses the field values from the transcluding tiddler. Template transclusion is indicated like so: {{||H1}}. For example, tiddler Test One contains this:

     {{||H1}}

It displays its own title, Test One, formatted as a header and a link according to the markup in the H1 tiddler. Centralizing headers also makes it easy to add CSS styling (which is a subject for another day).

That saves a little typing, but it's not that impressive, so we'll take it a step further. If you look at the recent post I made about lists and fields,  you'll see this lovely bit of HTML/wikitext:

     <ul><$list filter="[all[current]tagging[]] +[sort[title]]">
     <li><$link>{{!!title}}</$link> - {{!!sdesc}}</li>
     </$list>
     </ul>

Basically, this creates an ordered list of links to all tiddlers tagged by the current tiddler plus the short description (sdesc) field of each listed tiddler. This is long and complex enough that condensing it is useful, so I made the DLIST (descriptive list) template tiddler:

     !!!! Content
     <ul><$list filter="[all[current]tagging[]] +[sort[title]]">
     <li><$link>{{!!title}}</$link> - {{!!sdesc}}</li>
     </$list>
     </ul>

Adding {{||DLIST}} to any tiddler inserts level four "Content" header plus the usual bullet list of tagged tiddlers/descriptions. It's a lot easier to type too. Using this technique, I can quickly create every tag tiddler using cut/paste. Each contains:

     {{||H3}
     {{||DLIST}}

As a final note, naming conventions are essential! Using tiddler names that are easy to differentiate simplifies organizational tasks and helps you remember what's what. Personally, I use:

  • all lower case - tag tiddlers
  • all caps - template tiddlers
  • capitalized words - content tiddlers

There's no right or wrong answer here, use what makes sense to you.
So there you have it, TiddlyWiki templates in a nutshell. I hope this is useful and that you'll consider checking out TiddlyWiki. It really is a nifty organizational tool.

3 comments:

  1. Very cool! Any plans to try and resurrect the colony with new players? Or you going to take a break from pbem for a while?

    ReplyDelete
    Replies
    1. No plans at the moment. To be honest, my interest in gaming (both RPG and video) is fairly low at the moment. I think a break is going to be a good thing.

      Delete
  2. Enjoy your time off! Recharge the batteries. Don't stay away too long though.

    ReplyDelete

Note: all comments are moderated to block spammers. Please be polite.