I was thinking more about something as follows, which makes it possible, that the tiddler that contains the following code can easily be converted to a template too.
So it may be a bit unintuitive at first but in the long run it is much more flexible.
Same here. Though I would say, if you were to devise a spec by reverse-engineering the docs, you’d end up with a mess. Fact is, the docs are written by those “suffering” from the curse of knowledge.
I’ll get there but I’m surprised to find I’m feeling like I’m “just starting out” on this topic.
@pmario I’m not saying there’s anything wrong with the pattern, as such. I’m surprised there is no $template attribute on the $transclude widget. That’s intuitive and much shorter.
I think if a transclusion-widget needs a template there is something wrong in the concept of the code. Templates are usually resolved using transclusions.
The tiddler-widget sets the “currentTiddler” variable to a tiddler title and defines some class-variables.
If you do not need the class variables, your code can be reduced to a template itself.
I think this construction is much more flexible in the long run. Your own templates can manipulate the currentTiddler variable, because it is only a convention every UI element can use.
As @pmario notes, the familiar {{currentTiddler||template}} syntax is a shortcut for a transclude widget targeting “template” nested inside a <$tiddler> widget that assigns the specified value to the currentTiddler variable.
So, the way to think about it is that the <$transclude> widget is entirely concerned with the template. There is no attribute called “template” because the other attributes $tiddler and $variable are two different types of template.
If we didn’t have the word “transclude”, it is entirely possible that we’d be calling it the <$template> widget.
I’m slowly getting that and that exact thought ran through my head last night. Kind of explains some of the wrestling the docs need to go through, too.
If and when I truly get there, I may take a stab at improving them – though the style would be significantly different (part of the authoring trouble, I believe, is having to pay dues to the style currently in place).