Transclusion Confusion

72 views
Skip to first unread message

David Allen

unread,
Nov 9, 2017, 8:57:48 PM11/9/17
to TiddlyWiki
I'm having some trouble with multiple transclusions in tiddlywiki causing unwanted behavior.

Here's my setup:

I have a number of image tiddlers that are formatted as follows:

Title: Image_Blah_1
Tags: image
Text: <img src={{!!img_url}} class="modal_image"/>
category: Blah
img_url: theimageurl

I have a second tiddler in which I'm trying to transclude the previous image tiddlers as follows:

Title: TemplateModal
Text: <$transclude tiddler={{!!theImage}}/>
theImage: Image_Blah_1
img_url: donotdisplaythis

What's happening is the transclusion of Image_Blah_1 into TemplateModal happens before the img_url reference is resolved in Image_Blah_1, so that the <$transclude> widget inserts the following into TemplateModal:

<img src={{!!img_url}} class="modal_image"/>

Which then becomes

<img src=donotdisplaythis class="modal_image"/>

What I'm trying to do is get it to display as the following:

<img src=theimageurl class="modal_image"/>

Does anyone know how to get this to work?

Eric Shulman

unread,
Nov 9, 2017, 10:11:25 PM11/9/17
to TiddlyWiki
On Thursday, November 9, 2017 at 5:57:48 PM UTC-8, David Allen wrote:
Title: Image_Blah_1
Tags: image
Text: <img src={{!!img_url}} class="modal_image"/>
category: Blah
img_url: theimageurl

Title: TemplateModal
Text: <$transclude tiddler={{!!theImage}}/>
theImage: Image_Blah_1
img_url: donotdisplaythis

What I'm trying to do is get it to display as the following:
<img src=theimageurl class="modal_image"/>

Wrap the <$tranclude> within a <$tiddler> widget, like this:

<$tiddler tiddler={{!!theImage}}><$transclude tiddler={{!!theImage}}/></$tiddler>

This will set the context for the data reference within the transclusion to the tiddler being transcluded, rather than the tiddler in which the transclusion is embedded.

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas" (tm)
InsideTiddlyWiki: The Missing Manuals


BJ

unread,
Nov 10, 2017, 4:42:40 AM11/10/17
to TiddlyWiki
maybe

<$tiddler tiddler={{!!theimage}}><$transclude /></$tiddler>
Reply all
Reply to author
Forward
0 new messages