Mohammad,
Thanks for sharing. Yes I have seen this “nested view widgets before”. I think Eric makes use of this. It depends on the fact the
The content of the <$view>
widget is displayed if the field or property is missing or empty.
To illustrate this further you can see we can nest further;
\define linkify(tiddler field:"caption")
<$link to=<<__tiddler__>> >
<$view tiddler=<<__tiddler__>> field=<<__field__>> >
<$view tiddler=<<__tiddler__>> field=caption >
<$view tiddler=<<__tiddler__>> field="title" />
</$view>
</$view>
</$link>
\end
<<linkify test>>
This example also uses caption before the title if it exists.
What is interesting is the field can be the “title” to bypass the caption. But also you can use “text” which results in a form of transclusion that is linked to the source tiddler.
However to further the discussion here is how I would enhance the original macro;
\define linkify(tiddler field:"caption")
<$set name=tiddler value="$tiddler$" emptyValue=<<currentTiddler>> >
<$link to=<<tiddler>> >
<$view tiddler=<<tiddler>> field="$field$" >
<$view tiddler=<<tiddler>> field=caption >
<$view tiddler=<<tiddler>> field="title" />
</$view>
</$view>
</$link>
</$set>
\end
<<linkify>>
The above defaults to current tiddler so it can be used in any list that changes the currentTiddler, it also defaults to caption, the natural alternative to title. Not also how I depart from the <<__param__>>
style, somehow I never became comfortable with that.
Now here is an alternative which does the value nesting in a filter;
\define linkify(tiddler field:"caption")
<$set name=tiddler value="$tiddler$" emptyValue=<<currentTiddler>> >
<$link to=<<tiddler>> ><$text text={{{ [<tiddler>get[$field$]] ~[<tiddler>get[caption]] ~[<tiddler>get[title]] }}}/></$link>
</$set>
\end
<<linkify test description>>
The value of using the text field as a form of transclusion is interesting, so I may shortly post another variation.