See how I “push” the short form of the transclude futher;
I hope you all find the following “code patterns interesting” but it also illustrates a hard limit I come across.
Because I am not privy to this history and the approaches used in the core, yet I have spent a lot productive time with tiddlywiki, from the non-developer super user perspective, I see it from a different direction. It is interesting seeing the diversity of perspective of the same thing. As a result of my different perspectives I have developed some different “code Patterns” to use with transclusions.
Using the “current tiddler” as parameter(s)
{{anything||mytiddler}} {{||mytiddler}} {{filter||mytiddler}}
More often than not I use the {{||mytiddler}}
form because mytiddler is designed to make use of the fields and variables available already in the tiddler doing the transclusion. That is I have no need for parameters in this transclusion.
But If I wanted parameters for example I can reuse the current tiddler, eg filter as parameter;
{{ [all[shadows+tiddlers]tag[$:/tags/ViewToolbar]sort[]] || mytiddler}}
with my tiddler;
<$list filter="[subfilter<currentTiddler>]" >
</$list>
But I can also test if the currentTiddler is a filter,
\define filter-prefix() [
<$list filter="[<currentTiddler>prefix<filter-prefix>]" >
process current tiddler as filter
</$list>
and if the <<currentTiddler>>
value is needed I can still use this;
<$set name=myfilter value=<<currentTiddler>> emptyValue="default filter">
<$tiddler tiddler=<<storyTiddler>> >
using <<myfilter>> and <<currentTiddler>>
</$tiddler>
</$set>
With the above methods the currentTiddler is the parameter(s) to the transclusion and this opens many possibilities such as I could pass a fieldname as a parameter to a transclusion, then use this to get<currentTiddler>
.
What is the problem?
There is no problem if I can simply make use of existing fields and variables in the transclusion, be it the currentTiddler, StoryTiddler or the transcluded tiddler itself.
The problem arises it I want to provide more than one “parameter” in the shorthand transclusion.
What kind of parameters may I want to set and pass more than one of in the shorthand transclusion?
- a tiddler title/list of titles
- a filter
- a string
- one or more fieldnames and/or their values
- one or more variable names and/or their values
So yes if we could pass additional parameters to the shorthand transclusion I could make a larger set of snazzy shorthand transcludes.
A design and debug trick
I tend to make use of the transclusion variable when building such shorthand transcludes;
<<transclusion>>
Documented here
Format
- the title of the current tiddler
- the title of the tiddler being transcluded
- the name of the field being transcluded
- the name of the property name or index being transcluded
- the name of the subtiddler being transcluded from a plugin
- is the interesting one, because it returns what I call the “code tiddler” ie the tiddler the “current tiddler is transcluding”, “mytiddler” in the above examples, so I can make use of the title of the transcluded tiddler if I want.