Transclusion and currentTiddler

I have some problems with transclusion.

Be a “fu” tiddler with a “hint” field valued as “clue” and a text as {{||bar}}.
Be the “bar” tiddler with a texte as here is <<currentTiddler>> with {{!!hint}}.

On display, fu will show “here is bar with clue”.

That I see “clue” was inded what is OK (although the transclusion doc does not tell of the {{||tiddler}}mechanism) but how can it works so if the currentTiddler is not “fu” baut “bar” ? I was thinking that currentTiffler would be “fu”, the transclusion modifying only the code to be exceuted and not its context.

Is there a way to get back the “fu” tiddler name when in “bar”?

Very perplex,


Jean-Pierre

The last section of the Transclusion docs talks about, how a template transclusion {{||template}} is evaluated.

That should give you the info. … A templated transclusion doesn’t change the currentTiddler variable. So the template can work with the content from the “calling” tiddler.

1 Like

I don’t want to think about this question, without proper tiddler names. TW templating system is complex, because several layers of indirect references are involved. IMO using meaningless tiddler names adds 1 more level of complexity.

I think this is 1 reason, why you confused yourself. …

There is an interesting article: Never Use Foo, Bar, Baz, etc. in Software Documentation about meaningless variable names.

Just my opinion.

3 Likes

@pmario OK, I recheck my example code. it worj-ks as intended. with fu and bar. I wanted to avoid putting my whole real stuff here. Go to check with greater attention where I made an error (for my example, which I coded before posting here, I cannot say as I modified it.)

Today is a day of greater concern for bugs proliferation for me, it seems :wink:

Okay, I got where I was wrong.

I was thinking that I was using the {{||model}} notation but in fact I did use the transclude widget. I could not use the first notation because the model is not a fix name but is holded by a variable, and that notation cannot do it. So my code was:

<$let template={{!!template}}>
<$set name=refs filter="[{!!tabname}subfilter<refsFilter>]">
<$tiddler tiddler=<<refs>>><$transclude tiddler=<<template>> mode=block/></$tiddler>
{{||$:/user/core/templates/listFormDebugTemplate}}
</$set>
</$let>

As I read the transclude widget, I cannot see how to do it with the filtered transclusion I need! Which seems odd as I know that every notation is translated to widgets. So thtat definitely indicates there is a gap within my tiddlywiki knowledge!

I think filtered transclusion is the key word here. … You are right. It does translate to widgets, but it uses some “hardcoded assumption”. So to say it’s an opinionated convenience function. If you need fine grained control you should use the <$list widget. … That’s basically the translation target for filtered lists.

As you found out, the possibilities with {{tiddler transclusions}} and {{title||template}} transclusions are not on par with the corresponding widgets.

The same is true for {{{ [[filtered transclusions]] }}} — There are some discussions on github, how we could improve that “gap”.

Introduce shortcut syntax for transclusion passing parameters via variables – long text warning :wink:

Just for clarity, my code is now simplified into:

<$set name=refs filter="[{!!tabname}subfilter<refsFilter>]">
<$list filter=<<refs>> template={{!!template}}/>
{{||$:/user/core/templates/listFormDebugTemplate}}
</$set>

This is fine for me but needs a better documentation and would be felt more natural (hum!) if the transclude widget would be used instead of the list widget.

pmario, it gives me such relief to read this coming from a user at your level. I often struggle with the foo bar biz jargon in coder circles. Though I try to raise my own questions with titles and fieldnames that intuitively reinforce the data structure I’m modeling, I’ve always felt like too much of a novice to articulate this critical nudge.