Is there a way to apply a template stored in the field of another tiddler?

83 views
Skip to first unread message

Si

unread,
Jul 25, 2021, 3:05:52 PM7/25/21
to TiddlyWiki
Say for example I have the following tiddler:

title: MyTemplate
text: Hello
template: <$link to={{!!title}}> {{!!title}} </$link>

I thought I would be able to call this template in another tiddler like this:

{{Tiddler to link to||MyTemplate!!template}}

But alas not. It seems like the template must be stored in the text field. Is this correct? Is there a suitable workaround?

Thanks in advance for your help.

TW Tones

unread,
Jul 25, 2021, 8:11:17 PM7/25/21
to TiddlyWiki
Si,

Yes you can, apply a template stored in the field of another tiddler? and/or find a workaround.

Keep in mind the double curly braces are in face a short hand version of using the transclude widget.

Because you are referencing the current tiddler using the !!title you should be able to do this;

<$tiddler tiddler="Tiddler to link to">
<$transclude tiddler="MyTemplate" field="template"/>
</$tiddler>

<$transclude tiddler="MyTemplate" field="template"/> works on the current tiddler.

Since there are a few combinations of this it would take time to give an exhastive answer, so please try this first.

Tones

Si

unread,
Jul 26, 2021, 1:15:24 PM7/26/21
to TiddlyWiki
Thanks Tones!

Do you think it would be helpful if a shorthand like {{Tiddler to link to||MyTemplate!!template}} worked? Maybe I should make a feature request?

TW Tones

unread,
Jul 27, 2021, 8:46:30 AM7/27/21
to TiddlyWiki
Si,
 
Do you think it would be helpful if a shorthand like {{Tiddler to link to||MyTemplate!!template}} worked? Maybe I should make a feature request?

Perhaps but I have a faded memory in relation to this, there may be a reason why not.

I have being looking for {{tiddler|whats here?|template}}

 Not valid for transclusions
  5. {{||tiddlername!!caption}} as it asks for the field caption in tiddlername, but insists on using the currentTiddler.

. Below are some untested possibilities

My template could contain  {{MyTemplate!!template}} 
thus {{Tiddler to link to||MyTemplate}} will produce the same result.

Or use filters and the filtered transclusions

<$tiddler tiddler="Tiddler to link to" >
{{{ [{MyTemplate!!template}] }}}
</$tiddler>
 
Or use the long form

<$tiddler tiddler="Tiddler to link to" >
<$transclude tiddler=MyTemplate field=template />
</$tiddler>

Regards
Tones
Reply all
Reply to author
Forward
0 new messages