Transclude current tiddler avoiding recursion

244 views
Skip to first unread message

Danielo Rodríguez

unread,
Aug 30, 2016, 12:20:26 PM8/30/16
to TiddlyWiki
Hello everyone,

I am very close to achieve something that I want, which is a custom view template showing the current tiddler along with other tiddlers in tabs. 

In the first tab I want to show the current tiddler, and other tiddlers in other tabs. Showing other tiddlers works flawlessly, but showing the current one end in a Recursive transclusion error.

How can I adjust the template to avoid this but use the default view template?
This is the current template that I'm using with the tabs macro:

<!-- This template should be used with the tabs macro  -->
<$tiddler tiddler=<<currentTab>>>
<$transclude tiddler="$:/core/ui/ViewTemplate"/>
</$tiddler>


Jeremy Ruston

unread,
Aug 30, 2016, 12:27:50 PM8/30/16
to tiddl...@googlegroups.com
Hi Danielo

The recursive transclusion error is because you've got nested invocations of $:/core/ui/ViewTemplate with the same value for currentTiddler. You probably want to use a different template for the tiddlers that are nested in tabs.

Best wishes

Jeremy

--
Jeremy Ruston
--
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/47a377ca-62fd-4df0-879d-0751a6b8c938%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Danielo Rodríguez

unread,
Aug 30, 2016, 1:26:41 PM8/30/16
to TiddlyWiki
Hello Jeremy,

Of course that is the problem.

I want to show the tiddler as it will render normally, that's why I need to use core's the viewTemplate.
Is not any mechanism to limit the number of recursions?

Jeremy Ruston

unread,
Aug 30, 2016, 1:41:29 PM8/30/16
to tiddl...@googlegroups.com
HI Danielo

Of course that is the problem.

I want to show the tiddler as it will render normally, that's why I need to use core's the viewTemplate.
Is not any mechanism to limit the number of recursions?

But you’re already inside the core’s ViewTemplate, so you can’t transclude it again with the same currentTiddler without creating the recursion. You’re modifying the view template to include a bunch of tabs, and then one of those tabs is transcluding the same view template.

The only way out is to detect the recursion and render something else instead.

Perhaps you could show a mockup of what you’re trying to achieve?

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.

Danielo Rodríguez

unread,
Aug 30, 2016, 1:53:10 PM8/30/16
to TiddlyWiki



But you’re already inside the core’s ViewTemplate, so you can’t transclude it again with the same currentTiddler without creating the recursion. You’re modifying the view template to include a bunch of tabs, and then one of those tabs is transcluding the same view template.

Yes, I know, that's the problem.
 
The only way out is to detect the recursion and render something else instead.

I have a mechanism to detect the recursion:

<!-- This template should be used with the tabs macro  -->
<$list filter="[is[current]!field:title<currentTab>]">
<$tiddler tiddler=<<currentTab>>>
<$transclude tiddler="$:/core/ui/ViewTemplate"/>
</$tiddler>
</$list>



 but I don't know how to guarantee to show the same thing the view template would do without using the view template.
 

Perhaps you could show a mockup of what you’re trying to achieve?


Of course, here it is an screenshot opened on the tab that works



Regards

Jeremy Ruston

unread,
Aug 30, 2016, 1:56:11 PM8/30/16
to tiddl...@googlegroups.com
Hi Danielo

 but I don't know how to guarantee to show the same thing the view template would do without using the view template.

I think you’ll need you’re own clone of the guts of the default ViewTemplate, in particular the list widget that transcludes the view template segments. Presumably you’ll want to exclude the view template segment generating the tabs so as to avoid the recursion.

Best wishes

Jeremy

 

Perhaps you could show a mockup of what you’re trying to achieve?


Of course, here it is an screenshot opened on the tab that works



Regards

--
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.

Danielo Rodríguez

unread,
Aug 30, 2016, 2:14:42 PM8/30/16
to TiddlyWiki
Hello Jeremy

> Presumably you’ll want to exclude the view template segment generating the tabs so as to avoid the recursion.

Exactly! that's it.

Isn't any way to influence a filter from the outside? Maybe setting or erasing certain variable?

Mmm, maybe changing the tabs template to only show in case there is no currentTab variable set. Maybe this last option works. I'll give it a try...

Danielo Rodríguez

unread,
Aug 30, 2016, 2:47:21 PM8/30/16
to TiddlyWiki
> Mmm, maybe changing the tabs template to only show in case there is no currentTab variable set. Maybe this last option works. I'll give it a try...

Rethinking about this that will not work neither. It will certainly avoid the recursive transclusion, but because the tiddler is folded it will not show anything.

My only option is to create a clone of the default view template avoiding the tabs transclusion via filter and removing the folding part. Then I should make sure that it is up to date with core for the best experience.

Mat

unread,
Aug 30, 2016, 3:11:58 PM8/30/16
to TiddlyWiki
Danielo, I had the exact same problem a week ago and solved it like you see in Versioning (I even make a comment about it on that very front tiddler).


<:-)

Danielo Rodríguez

unread,
Aug 30, 2016, 4:21:26 PM8/30/16
to TiddlyWiki
Hello Mat,

Of course I took a closer look at your work about versionning. But I have a challenge that you don't : you use a tag to trigger the view template, and I don't want to attach any tag to the current tiddler. So my view template should be triggered in a different way, same thing for hidding the default body.

Regards

Mat

unread,
Aug 30, 2016, 4:48:21 PM8/30/16
to TiddlyWiki
Another way to target a tiddler (...that I probably have mentioned already over these past days) is ctrlpanel>settings>titles as links and then target the specific tiddler with:

body .tc-tiddler-frame a[href="#NAMEOFTIDDLER"] {...}

nameoftiddler must be uri encoded. 

Contrary to Marios promising solution this doesnt require any change to the viewtemplate (...if one cares about such matters). 

I also have various tricks to hide tags that would be an acceptable solution.

<:-)

Mat

unread,
Aug 30, 2016, 4:50:23 PM8/30/16
to TiddlyWiki
ERRATA - the above targets the title, not the whole tiddler. Probably not useful for you then. Sorry!

<:-)



Danielo Rodríguez

unread,
Aug 31, 2016, 3:19:08 AM8/31/16
to TiddlyWiki
Finally! I got it!

Here is how I did it:

* Use a special tab macro that renders everything except the current tiddler.
* That macro adds a special button as the first one, which corresponds to the current tiddler
* All the tabs folds the current tiddler and transclude the target tiddler using core's view template
* The first tab is an exception and acts the opposite:it unfolds the current tiddler and shows nothing, so it looks like the tab content is the current tiddler

Easy and without touching a single core tiddler.

Regards

Conner Phillips

unread,
Jun 10, 2017, 3:29:23 AM6/10/17
to TiddlyWiki
Any chance you could share this macro?

Conner Phillips

unread,
Jun 10, 2017, 8:06:09 AM6/10/17
to TiddlyWiki
I believe I have found this code in your NoteSelf fork, but it is quite dense. I will have to sit down when I get a chunk of time and take a closer look. Do you have a simpler prototype of this macro set-up or is that pretty much as clean as it gets? Thanks!

Danielo Rodríguez

unread,
Jun 11, 2017, 3:27:08 AM6/11/17
to TiddlyWiki
Hello Conner,

NoteSelf is not a fork, it is my own project.
The macro you are looking for is not on noteself repo, it's on tiddlypouch one.
I'll try to find it out
Reply all
Reply to author
Forward
0 new messages