how to generate a unique state tiddler for a reveal in a template

46 views
Skip to first unread message

Andrés Pérez

unread,
Oct 7, 2018, 9:44:54 PM10/7/18
to TiddlyWiki
So I have a reveal in a template tiddler because I need it to be reusable and unique per tiddler that is using the template.
Basically I want a reveal in a tiddler that when clicked shows some text. I then want to use that same reveal in multiple tiddlers by just transcluding the template tiddler but having the reveal only show up on the tiddler where it is clicked and not the others.

So, I tried with a macro where it builds the state tiddler like this:

\define stateName(name) "$:/state/{{!!title}}/$name$"

That works fine when I just call the macro in a text field by itself. So in a tiddler named 'test', adding this <<stateName foo>>  results in $:/state/test/foo

If I try it as the attribute for a reveal (<$reveal type="nomatch" state=<<stateName foo>> text="show">) the state tiddler which is created is $:/state/{{

Can I do what I want to do?


Mark S.

unread,
Oct 7, 2018, 10:52:31 PM10/7/18
to TiddlyWiki
In order to concatenate, the macro needs either placeholders (e.g. $name$) or variables (e.g. $(variable)$). In this case, $(currentTiddler)$ is already available. So you should be able to use:

\define stateName(name) $:/state/$(currentTiddler)$/$name$

Good luck!
-- Mark

Andrés Pérez

unread,
Oct 7, 2018, 11:14:32 PM10/7/18
to TiddlyWiki
/facepalm
yup. That does work. thanks!
Reply all
Reply to author
Forward
0 new messages