Use template in $:/core/ui/ViewTemplate as view template in tabs macro

178 views
Skip to first unread message

Danielo Rodríguez

unread,
Aug 29, 2016, 6:02:52 PM8/29/16
to TiddlyWiki
Hello,

I was wondering why I can do the following:

{{HelloThere||$:/core/ui/ViewTemplate}}

But I can't use the template $:/core/ui/ViewTemplate as template for the tabs macro. Is there any way to emulate it?

Regards

Tobias Beer

unread,
Aug 30, 2016, 1:51:14 AM8/30/16
to TiddlyWiki
Hi Danielo,
 
{{HelloThere||$:/core/ui/ViewTemplate}}

I imagine this doesn't work,
because the tabs macro runs with a variable currentTab,
leaving currentTiddler untouched.
And that is probably why the following
will give you a recursion error for each tab:

<<tabs
"HelloWorld [[tabs Macro]]"
"HelloWorld"
"$:/state/test-tabs"
"some-class"
"$:/core/ui/ViewTemplate">>

Recursive transclusion error in transclude widget

Since you're obviously already rendering the ViewTemplate for currentTiddler,
which is where the tabs macro is in.

Best wishes,

Tobias.

Danielo Rodríguez

unread,
Aug 30, 2016, 3:06:33 AM8/30/16
to TiddlyWiki
Thanks Tobias,

So in order to fix this, the tabs macro should modify the current tiddler variable to the selected tab, right?

Danielo Rodríguez

unread,
Aug 30, 2016, 3:08:00 AM8/30/16
to TiddlyWiki
I have been thinking about this... Maybe it's because I'm using the tabs macro as a component of the view template (tagged with the appropriate tag). But I'm not sure if this happens in a regular tiddler. Because of what you exposed, I think the result would be the same

Danielo Rodríguez

unread,
Aug 30, 2016, 7:34:22 AM8/30/16
to TiddlyWiki

Hello Tobias,

I have modified the tabs macro this way for easier comparison here is a diff https://www.diffchecker.com/tXBz8Q8L):

\define tabs-cool(tabsList,default,state:"$:/state/tab",class,template)
<div class="tc-tab-set $class$">
<div class="tc-tab-buttons $class$">
<$list filter="$tabsList$" variable="currentTab"><$set name="save-currentTiddler" value=<<currentTiddler>>><$tiddler tiddler=<<currentTab>>><$button set=<<qualify "$state$">> setTo=<<currentTab>> default="$default$" selectedClass="tc-tab-selected" tooltip={{!!tooltip}}>
<$tiddler tiddler=<<save-currentTiddler>>>
<$set name="tv-wikilinks" value="no">
<$transclude tiddler=<<currentTab>> field="caption">
<$macrocall $name="currentTab" $type="text/plain" $output="text/plain"/>
</$transclude>
</$set></$tiddler></$button></$tiddler></$set></$list>
</div>
<div class="tc-tab-divider $class$"/>
<div class="tc-tab-content $class$">
<$list filter="$tabsList$" variable="currentTab">

<$reveal type="match" state=<<qualify "$state$">> text=<<currentTab>> default="$default$">

<$tiddler tiddler=<<currentTab>>>
<$transclude tiddler="$template$" mode="block">

</$transclude>
</$tiddler>
</$reveal>

</$list>
</div>
</div>
\end


Basically I have added a $tiddler widget to set the currentTiddler to the current tab before the template transclusion. I have also removed the second transclusion of the current tab. To be honest, I never saw that way of using a template: transcluding the template and then transcluding the tiddler inside it.

Danielo Rodríguez

unread,
Aug 30, 2016, 7:55:02 AM8/30/16
to TiddlyWiki
An alternative, and probably easier solution would be to just use a template like this:

<$tiddler tiddler=<<currentTab>>>
<$transclude tiddler="$:/core/ui/ViewTemplate"/>
</$tiddler>


Jeremy Ruston

unread,
Aug 30, 2016, 8:07:54 AM8/30/16
to tiddl...@googlegroups.com
Hi Danielo

That’s correct. We can’t change the tabs macro to store the current tab in the currentTiddler variable because it would break all the places where the tabs macro needs to be used without modifying the current tiddler. For example, in the info panel the currentTiddler is the tiddler being displayed, and we use the tabs macro to transclude the individual tabs. The content of those tabs needs to be able to operate on the currentTiddler to display the correct information.

Best wishes

Jeremy



--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/9a826297-2e37-44b4-b19b-4cd54035a486%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeremy Ruston

unread,
Aug 30, 2016, 8:10:56 AM8/30/16
to tiddl...@googlegroups.com
Hi Danielo

On 30 Aug 2016, at 12:34, Danielo Rodríguez <rdan...@gmail.com> wrote:

To be honest, I never saw that way of using a template: transcluding the template and then transcluding the tiddler inside it.

The way that the transclude widget works is that the content of the widget is used as a fallback if the transcluded content is missing.

Best wishes

Jeremy

Danielo Rodríguez

unread,
Aug 30, 2016, 8:36:55 AM8/30/16
to TiddlyWiki

The way that the transclude widget works is that the content of the widget is used as a fallback if the transcluded content is missing.

Best wishes

Jeremy


I realized after re-reading the documentation. Thanks. 
Reply all
Reply to author
Forward
0 new messages