I’m a little confused when trying to use variables.
Mainly, I have a lot tag tiddlers, and I like when they contain toc-selective-expandable, so I can effectively navigate through and grasp the contents of my wiki. But when creating new tag each time I need to copy/paste and then modify the name in toc, so it shows proper list. Therefore I’m interested in creating a template:
So first of all, how can I use such variable in macrocall?
And the other thing, what is the difference between those 3 currentTiddler notations? I have also seen something like !!title, or something like this, so I would be most grateful if someone could explain to me what’s going on.
Oh and btw. I also happen to struggle with usage of mathematical operators. I’m interested in defining 2 variables, let’s say x=2 and y=3, and be able to perform x+y to obtain the result. Again, I would be most thankful for pointing out how to do it.
Did you try tag=<<currentTiddler>>?. Also its wise to put this in a tiddler tagged $:/tags/ViewTemplate so it appears on all tiddlers, and wrap it with a list widget to make it conditional ie on if has tags etc…
Unless you install a plugin for mathematics we use operators in filters to do maths. It’s quite simple once you are familiar with filters.
So you can do a lot in a single filter but using the let widget to define the variables and calculations involved is a self documenting and easy to read approach.
<<currentTiddler>> display the value in the variable currentTiddler
<$text text=<<currentTiddler>>/> display the value in the variable currentTiddler but convert to plan text. Nop camel case seen, not a link etc
<$text text={{{ [<currentTiddler>] }}} /> just another way to do the last example using the triple curly braces “filtered transclusion” to evaluate a filter
tag=<<currentTiddler>> indeed worked! Though the result was not (and is not) visible in the preview pane, which is a slight incovenience. I also added the $:/tags/ViewTemplate tag, which resulted in exactly the outcome I desired (thank you so much!!!) As you also suggested, I’ll try to wrap it with a list widget, but it’d be also most welcomed if you could show an example of such conditionality.
Also, before I added ViewTemplate tag, I tried to use it via Tiddler transclusion, but it didn’t work at all.
To transclude a tiddler and use it as a “template” for another tiddler, use this syntax
{{||Template_1}}
Note the “||” double vertical bars. This indicates that the “Template_1” tiddler’s content will be displayed, while using the containing tiddler’s field values (including the <<currentTiddler>> variable, which is the same as the {{!!title}} field value). Without the “||” vertical bars, the transclusion uses the “Template_1” tiddler’s field values, and thus the “toc-selective-expandable” macro’s tag=... parameter will always be tag="Template_1".
Thank you! It really did the trick. Right now I’m figuring out how to do some maths, using Evan Balster’s TiddlyWikiFormula
And I will also try to figure out how make templates conditional, since that’s not so clear for me yet.
No problem, this is a fundamental pattern to use in Tiddlywiki but now another approach available is the cascades but you can look into that another day