Docs about transclusion are still missing a few basic examples

I am reading https://tiddlywiki.com/#Transclusion%20in%20WikiText

It starts with a list containing five items:

  1. {{MyTiddler}} simplest form of transclusion, not hard to understand.

  2. {{MyTiddler||TemplateTitle}} not exactly obvious, but fortunately it links to https://tiddlywiki.com/#TemplateTiddlers , which links to https://tiddlywiki.com/#Transclusion%20with%20Templates , which has examples. Good.

  3. {{||TemplateTitle}} is also covered there.

  4. {{MyTiddler|Parameter}} full stop. This really needs a link to a tiddler with examples similar to https://tiddlywiki.com/#Transclusion%20with%20Templates . Because searching for things like “transclusion with parameters” gives results about parameters widget and \parameters pragma, which seem to be different things and only add more confusion.

  5. {{MyTiddler||TemplateTitle|Parameter|SecondParameter}} - looks like a combination of 2. and 4. Either providing an example for 4. will automatically fix this as well, or it will need its own example, if using 2. and 4. together implies additional complexity and subtleties.

I’ll admit, this is the first I’ve heard of transclusions with parameters, I’d also be interested in seeing an example :slight_smile:

Hi

Here is a simple example of parameterized transclusion:

{{$:/core/images/plus-button|50px}}

Here is $:/core/images/plus-button content:

\parameters (size:"22pt")
<svg width=<<size>> height=<<size>> class="tc-image-plus-button tc-image-button" viewBox="0 0 128 128"><path d="M64-.333c35.346 0 64 28.654 64 64 0 35.346-28.654 64-64 64-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64zM64 16c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48z"/><rect width="80" height="16" x="24" y="56" rx="8"/><rect width="16" height="80" x="56" y="24" rx="8"/></svg>

You can see how the parameter is declared using \parameters pragma, and then used as a variable <<size>>.

Fred

1 Like

Here is an example of a simple parameterized transclusion template:

How to use it:

Blah

Blah

{{myNote||note|lightgray}}

Blah

{{myNote||note}}

Result:

Fred

Thank you. I recall the svg parametrization from here How to visualize the content type of a tiddler? - #7 by EricShulman . Just that there it was brought up in a context more like “do it like this, trust me it works”. If you search for “template” in that thread - there’s zero results. So I could not make the logical connection with it while reading the template docs recently. I’m merely pointing to a gap in the docs, where your example would fit perfectly, since it shows both how to use the feature and a typical situation when using it is handy.

Example proposal:

SimpleParameterizedTransclusion.json (1.9 KB)

Comments and enhancements are welcome! :slightly_smiling_face:

Fred

1 Like

Second take:

Simple parameterized transclusion

SimpleParameterizedTransclusion.json (1.9 KB)

Parameterized template transclusion

ParameterizedTemplateTransclusion.json (1.5 KB)

Comments and enhancements are welcome! :slightly_smiling_face:

Fred

2 Likes