Parameterized transclusions

31 views
Skip to first unread message

Charlie Veniot

unread,
Jan 7, 2022, 11:06:06 AM1/7/22
to TiddlyWiki
When dealing with many parameters, I'm likely to setup a macro.

If things aren't too complicated, I much prefer transclusion and transclusion templates.

Why?  I can't explain it.  Macros annoy me for whatever reason.

Although a silly scenario, this sample code is about a little bit of filtering fun and to showcase how simple transclusion can be used for all sorts of things that are a little on the far side.

I've got a tiddler called "Some Tiddler" that has the text "Text in Some Tiddler"

I've got another tiddler with the following text:

{{Some Tiddler::red||tColouredText}}

{{Some Tiddler::green||tColouredText}}

{{Some Tiddler::blue||tColouredText}}


The template tiddler "tColouredText" has this text:

<$list filter="[<currentTiddler>!match[tColouredText]]">
<$vars thisTiddler={{{ [<currentTiddler>split[::]nth[1]] }}}
   thisColour={{{ [<currentTiddler>split[::]nth[2]else[black]] }}}>


<div style={{{ [[color:]addsuffix<thisColour>addsuffix[;]] }}}>
<$transclude tiddler=<<thisTiddler>>/>
</div>

</$vars>
</$list>

Reply all
Reply to author
Forward
0 new messages