-
Notifications
You must be signed in to change notification settings - Fork 115
Description
The transclude method [1] of the tiddler macro works so that if the same tiddler is to be transcluded "twice" (inside itself) [2], then it is not transcluded for the second time. This is done, obviously, to avoid loops. However, it can be desirable (and is desirable for me) to insert same templates with different parametrization one in another.
A (shortened) example..
tiddler ListTemplate
<<forEachTiddler filter '[tag[$1]]'
...
script 'var transclusionText = function(tiddler) { ... }'
write '"* [["+tiddler.title+"]] "+transclusionText(tiddler)'
>>
(transclusionText inserts the <<tiddler [[tiddler.title]]>>
thing, writing in a non-formal notation)
tiddler List1
<<tiddler [[ListTemplate]] with:someTag>>
(here goes the main list)
tiddler Item1 tagged with someTag
<<tiddler [[ListTemplate]] with:subItemsForItem1>>
(here goes the sublist which is to be displayed inside List1 as well)
The main issue is -- it's impossible to get the sublist shown without overwriting the config.macros.tiddler.transclude
method. When I do this with a plugin, I get problems with other plugins (at least I have to add the Require slice to those which hijack config.macros.tiddler.transclude
).
How to fix this in a backward-compatible way?
Well, a simple way would be to change config.macros.tiddler.transclude
a bit, namely substitute the lines 223 [2] with this:
if(!config.options.transclusionsNestLimit && (stack.indexOf(tiddlerName) !== -1) ||
config.options.transclusionsNestLimit && (stack.length+1 > config.options.transclusionsNestLimit))
Then, changing config.options.transclusionsNestLimit
would allow to define the possible depth of transcluding a tiddler into itself. This is a well-tested solution which I use these days (via a plugin that overwrites config.options.transclusionsNestLimit
), so it would be nice to get that in the core.
Of'course, a good fix will also contain the description of the option (in config.optionsDesc
), too.
[1] https://github.com/TiddlyWiki/tiddlywiki/blob/master/js/Macros.js#L217
[2] https://github.com/TiddlyWiki/tiddlywiki/blob/master/js/Macros.js#L223