How to transclude a subtiddler with template in TiddlyWiki?

Subtiddlers means the individual tiddlers stored within a plugin.

For example, I want to use a subtiddler ($:/boot/boot.js) in my own plugin to force override {{ $:/boot/boot.js ||$:/core/templates/tiddlywiki.js/load-tiddler}} in $:/core/templates/tiddlywiki5.js.

Initially, I thought it would be as simple as using the following code:

<$transclude tiddler="$:/plugins/myplugin" subtiddler="$:/boot/boot.js" template="$:/core/templates/tiddlywiki.js/load-tiddler"/>

However, I discovered that the TranscludeWidget does not have a template attribute and that its implementation relies on the currentTiddler variable. Therefore, this approach is not possible. Are there any other ways to achieve this?

1 Like

Hi @FSpark it is not possible to transclude a subtiddler through a template.

Rendering an ordinary tiddler through a template is accomplished by setting the currentTiddler variable to the title of the tiddler, and then transcluding the template. Within the template, one can then use constructions like {{!!myfield}} to render a particular field of the tiddler.

The trouble is that there is no way to set currentTiddler to a subtiddler and its containing plugin.

What are you trying to accomplish?

1 Like

Hi @jeremyruston. yes, I realized that so I am looking for other workarounds.

The above problem is what I encountered when developing this plugin:TW5-CSEncryption: Client-Side Encryption for TiddlyWiki5 on Node.js

Although it is solved by abandoning the template and directly hardcoding it, but considering that it is not general enough to use the fields of subtiddler in the future, so I am posting to ask, but it should still be able to reference them through ViewWidget, although there are indeed limitations.

Yes, in this case transclude widget is not working

<$transclude $tiddler="$:/core" $subtiddler="$:/core/ui/ViewTemplate/tags/default" template="$:/core/ui/ViewTemplate/body/code"/>

Also this is not working

<$view $tiddler="$:/core" $subtiddler="$:/core/ui/ViewTemplate/tags/default"/>

this is not working, result is empty

<pre><code>
<$set currentTiddler="$:/core/ui/ViewTemplate/tags/default">
<$view $tiddler="$:/core" $subtiddler="$:/core/ui/ViewTemplate/tags/default" mode="block"/>
</$set>
</code></pre>

This is not working, it render the whole current tiddler, not the tiddler we want

<pre><code>
<$view $tiddler="$:/core" $subtiddler="$:/core/ui/ViewTemplate/tags/default" mode="block"/>
</code></pre>

This seems to work, but is plain text, can’t use template or <pre> to add style

<$view $tiddler="$:/core" $subtiddler="$:/core/ui/ViewTemplate/tags/default"/>
1 Like

This is the working solution:

<pre>
<$view tiddler="$:/core" subtiddler="$:/core/ui/ViewTemplate/tags/default" mode=block format=text/>
</pre>

<$view> will render the body of $:/core/ui/ViewTemplate/tags/default from the plugin $:/core as text element on the HTML, and wrap the text element with <pre> will render it as code block.

1 Like