transclusion and parameterized template

78 views
Skip to first unread message

Jean-Pierre Rivière

unread,
Apr 27, 2021, 11:24:01 AM4/27/21
to TiddlyWiki
The transclude widget dos not offer any template use option.

the wiki syntax for transclusion requires a fixed template although it allows for a computed source tiddler.

That is:

we can have {{<<ds>>!!temp}}

but not {{<<ds>>!!<<temp>>}}

and it would be fine to get <$transclude tiddler=<<ds>> template=<<temp>>/>

I also tried to have a tiddler where the "datasource" and "template" field where valorized at my target values and whose text was

{{<$transclude field=datasource>>!!<$transclude field=template/>}}
{{<$transclude field=datasource>>!!my-real-template}}

the second form does work.

I tried some tricks with text and wikify widgets, but I've never been able to parametize the template tiddler name on way or another.

-- 
Jean-Pierre

Saq Imtiaz

unread,
Apr 27, 2021, 11:45:35 AM4/27/21
to TiddlyWiki
Two things that might be helpful:

1) {{tiddlerName||templateName}}

2) the above is a shortcut syntax for
<$tiddler tiddler="tiddlerName">
<$translude tiddler="templateName">
</$tiddler>

Jean-Pierre Rivière

unread,
Apr 28, 2021, 6:04:07 AM4/28/21
to TiddlyWiki
Than you Saq!

I had read the «transclusion with templates" doc several times. The hint you've just gave me was not evident from my reading. Although I was skeptical about not finding the widget equivalent of {{tiddler||template}} because I know that each wiki syntax is translated into widgets.

Here is the code if the tiddler used as a form holds two fields "datasource" and "template". The block mode is needed for full wiki syntax support (like a !!title)

<$vars temp={{!!template}}>
<$tiddler tiddler={{!!datasource}}><$transclude tiddler=<<temp>> mode=block/></$tiddler>
</$vars>

Saq Imtiaz

unread,
Apr 28, 2021, 6:46:45 AM4/28/21
to TiddlyWiki
Something you may find useful:

With the Internals plugin installed, you can turn on the preview in the editor and see the parse tree and widget tree for any wikitext.

Reply all
Reply to author
Forward
0 new messages