What's the reason for no $template attribute in $transclude ? (but yes in {{..}} )

Headline pretty much says it.

When $transclude was revamped (but actually even before that), what is the reason to not include a param to set a template for the output?

It often seems that one is forced to use the short form {{...|...}} syntax… which is a bit odd considering how the short form does use the real $transclude (…right?) …and in doing so, one does not have access to all the other goodie params that $transclude offers.

So what is the reason for not including a template param in the widget? It seems it would be complete if it had one.

Tx

1 Like

@twMat see this prior discussion: $transclude $variable --> template? - #12 by jeremyruston

Appreciated! Jeremys note that:

If we didn’t have the word “transclude”, it is entirely possible that we’d be calling it the <$template> widget.

made me chuckle. (I mean, he’s not joking but “oooooh, but of course, now I get it!”)

The tiddler-widget does set some variables.

  • currentTiddler
  • missingTiddlerClass
  • shadowTiddlerClass
  • systemTiddlerClass
  • tiddlerTagClasses
title: test-tiddler
tags: asdf

<$tiddler tiddler="test-tiddler">

<<missingTiddlerClass>>
<<shadowTiddlerClass>>
<<systemTiddlerClass>>
<<tiddlerTagClasses>>

</$tiddler>

You get this:

If you use the short form you can transclude the “template” by placing it inside the curly braces {{template}}, then you can apply it to the current tiddler using {{||template}} or named tiddler {{named||template}}.

If you want to expand this to the long form of transclusion, the current tiddler or named tiddler, is not part of the transclude widget it is found in the current tiddler context.

  • You can set current tiddler, or use the $tiddler widget or just accept the current value when using $transclude
  • This is why you can’t find it in the transclude widget, it , the template, is the transclude widget.

I hope this helps conceptualise and answer the question.

1 Like