Using the tiddler title and a prefix as icon and tag filter

92 views
Skip to first unread message

Alessio Staltari

unread,
Mar 7, 2021, 12:22:01 PM3/7/21
to TiddlyWiki
Hello,
I made a template to display an image and a list of tiddlers based on the title of the tiddler I use the template with, so the data tiddlers just need:

{{||CustomTemplate}}

Transcluding the image is pretty straightforward, the image is in another tiddler with the same name of the data tiddler and the .png suffix:

<$transclude tiddler={{{ [{!!title}addsuffix[.png]] }}}><$view field="body"/></$transclude>

The list of tiddlers is a bit trickier; I need to add a prefix to the tiddler name for the tag filter (Gifts.Tiddler) and another tag; I ended up using $set and a variable:

<$set name="myVariable" value={{{ [{!!title}addprefix[Gifts.]] }}}>
<$list filter="[tag<myVariable>tag[Gifts.Core]]">
<$link to=<<currentTiddler>>><$view field=title/></$link>,&nbsp;</$list>
</$set>

It works as intended, but I wonder if it would be better to add the prefix directly inside the $list filter instead of using a variable and $set.

Eric Shulman

unread,
Mar 7, 2021, 2:27:43 PM3/7/21
to TiddlyWiki
On Sunday, March 7, 2021 at 9:22:01 AM UTC-8 staltari...@gmail.com wrote:
<$set name="myVariable" value={{{ [{!!title}addprefix[Gifts.]] }}}>
<$list filter="[tag<myVariable>tag[Gifts.Core]]">
<$link to=<<currentTiddler>>><$view field=title/></$link>,&nbsp;</$list>
</$set>

The technique you used is needed because you need to construct the tag value before you use it as a parameter to the tag[...] filter.

However, your code can be written more compactly, like this:
<$vars myVariable={{{ [{!!title}addprefix[Gifts.]] }}}>
<$list filter="[tag<myVariable>tag[Gifts.Core]]"><$link />,&nbsp;</$list>
</$vars>

* use $vars instead of $set
* use $link with the default values for to="..." and the display of the title text

enjoy,
-e

Alessio Staltari

unread,
Mar 7, 2021, 4:01:20 PM3/7/21
to TiddlyWiki
Thanks.
Reply all
Reply to author
Forward
0 new messages