Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested transclusions of the same template are not allowed #172

Open
YakovL opened this issue Nov 23, 2014 · 0 comments
Open

Nested transclusions of the same template are not allowed #172

YakovL opened this issue Nov 23, 2014 · 0 comments
Labels

Comments

@YakovL
Copy link
Contributor

YakovL commented Nov 23, 2014

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

@pmario pmario added the issue label Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants