Why does the Transclude widget not have a template parameter?

87 views
Skip to first unread message

TonyM

unread,
Apr 1, 2020, 11:46:20 PM4/1/20
to TiddlyWikiDev
Folks,

Just wondering why the Why does the Transclude widget not have a template parameter?

It seems that the short forms `{{||template}}` '{{tiddlername||template}}` readily permit this.

I think since the transclude widget does not include this could be a little confusing, it would also make setting templates programmatically much easier.

More often than not widgets provide the more comprehensive set of options and parameters than its shorter forms. But not in this case. 

Regards
Tony

Jeremy Ruston

unread,
Apr 2, 2020, 4:49:43 AM4/2/20
to tiddly...@googlegroups.com
Hi Tony

The construction {{title}} generates the following widget structure:

<$tiddler tiddler="title">
<$transclude tiddler="title"/>
</$tiddler>

The construction {{title||template}} generates the following widget structure:

<$tiddler tiddler="title">
<$transclude tiddler="template"/>
</$tiddler>

See:

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/b56af0f5-4911-4063-81d8-9c89efb3dd4c%40googlegroups.com.

TonyM

unread,
Apr 2, 2020, 7:39:09 AM4/2/20
to TiddlyWikiDev
Jeremy

That explains it well thanks. I still see value in being able to say

<$transclude currentTiddler=tiddlername tiddler=templatetiddler/>

Which is a direct equivalent of
'{{curentTiddler||tiddlername}}' because its such a fundamental action which would be helpful in a number of cases.

Regards
Tony

PMario

unread,
Apr 2, 2020, 8:50:17 AM4/2/20
to TiddlyWikiDev
On Thursday, April 2, 2020 at 1:39:09 PM UTC+2, TonyM wrote:
Jeremy

That explains it well thanks. I still see value in being able to say

<$transclude currentTiddler=tiddlername tiddler=templatetiddler/>


I would name it: <$transclude tiddler=tiddlername template=templatetiddler/> .... otherwise it would be very confusing for users.

eg: {{tiddlername||templatetiddler}} is the current structure and the transclude widget reflect this, to make it easy to use.

-mario

Jeremy Ruston

unread,
Apr 2, 2020, 9:57:36 AM4/2/20
to TiddlyWikiDev
Hi Tony

The <$tiddler> and <$transclude> widgets are different because they do different things. The goal of widgets is to be small, reusable, generic primitives; the utility comes from combination. The goal of wikitext syntax such as double curly braces syntax is to make common idioms easier to type. The design of TiddlyWiki makes a careful distinction between those layers to give us flexibility and simplicity.

Best wishes

Jeremy
> --
> You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/05f64254-77b7-4166-ac8f-d465af355a0e%40googlegroups.com.

TonyM

unread,
Apr 3, 2020, 3:26:44 AM4/3/20
to TiddlyWikiDev
Mario,

The reason I did not suggest that was its not backwardly compatible, since the transclusion widget currently uses tiddler= to represent the tiddler to be transcluded and "defaults to currentTiddler".

Jeremy,

I have played with a few alternatives like macro's to do the equivalent and they are just not as convenient, we could say the transclusion widget defaults to current tiddler and we can't override this with a parameter unlike other widgets. If we had such a parameter I could set the effective currentTiddler without needing to resort to other code, which increases the complexity rapidly.

I know transclusion may mean something subtly different to you, but for new and regular users it is to include the content from elsewhere. We are told the short form `{{||template}} or {{tiddlername||template}}` but the "widget form" is not available.

Alternatively a new widget perhaps <$template [tiddler=tiddlername] template="templatetiddler" mode=block> when the default tiddlername is currentTiddler. New users hear the word template a lot, but its use is only in the short form of a transclude widget and is  a parameter in other widgets.

I will leave it to you, of course, but if you ever find yourself in that part of the code please consider this idea.

Regards
Tony

Joshua Fontany

unread,
Apr 4, 2020, 3:38:26 PM4/4/20
to TiddlyWikiDev
Tony,

It took me a little while to wrap my head around how the short-form `{{tiddler||template}}` is "rendered".

Basically, the <$transclude> widget, without a "parent" <$tiddler> widget wrapped around it IS a "template widget" because anything transcluded will use the "current" currentTiddler variable as its context.

Because in the short for the template parameter will default to the tiddler parameter, it seems like we are "inserting" that tiddler all in one go, but it is important to realize that it is "unpacked" to the nested structure:

<$tiddler tiddler="CONTEXT">
<$transclude tiddler="TEMPLATE"/>
</$tiddler>


Best,
Joshua Fontany

TonyM

unread,
Apr 4, 2020, 8:00:18 PM4/4/20
to TiddlyWikiDev
Joshua,

I think that explanation is useful.

The fact is I write most of my code with currentTiddler the target and use set or list to alter this value as needed.

I have being using the templating mechanism to great effect, using `{{||template}}` and relying on the context, ie currentTiddler is a common application. I have also developed solution where the context is set eg {{edit||$:/autotag}} will transclude all tiddlers tagged $:/autotag/edit and  {{edit||$:/autotag/actions}} will transclude all tiddlers tagged $:/autotag/actions/edit 
thus I can use actions={{edit||$:/autotag/actions}}, in these cases $:/autotag/actions/edit and $:/autotag/edit are sophisticated template tiddlers.

The issue is when I want to programmatically alter the "currentTiddler" used in the transcludes. There are half a dozen methods all of which complicate the code. eg a macro's etc...

All I am asking for is a native method to parameterise the long form, as we can with literals in the short form.

So it we keep the transclude widget as is but permit setting the currentTiddler in a parameter I could use the much simpler form using your terminology
<$transclude tiddler=<<transcludedtiddler>> context=<<currentContext>>/>

However the effort to persuade anyone on this simple "improvement" has being a little long winded. 

Regards
Tony
Reply all
Reply to author
Forward
0 new messages