This is a stripped-down version of a single section of Grok TiddlyWiki, optimized for fast loading and readability by search engines. Some features are missing.

For the full Grok TiddlyWiki experience, please visit the wiki version of this page.

Wr:Transclusions

 16th October 2024 at 8:21pm

Transclusions of fields, variables, procedures, functions, and macros are an essential part of TiddlyWiki. Here's the standard syntax for including bits and pieces from other places in a tiddler.

See Updated Summary of Transclusion Syntax for a more detailed treatment.

Transclude the text field of a tiddler

{{Sn:IncludeMe}}
{{Sn:IncludeMe!!text}}

Here is some text to be transcluded.

Here is some text to be transcluded.

Transclude a specific field of a tiddler, here caption

{{Sn:IncludeMe!!caption}}

Include me please!

Transclude an index from a data tiddler (The Metadata tiddler contains details about Grok TiddlyWiki like its version number and project URL.)

//Grok TiddlyWiki// version {{Metadata##version}}

Grok TiddlyWiki version 2.0.0

Transclude a tiddler through a template

{{Sn:IncludeMe||Sn:BoldfaceTemplate}}

Here is some text to be transcluded.

Transclude the current tiddler through a template

{{||Sn:CaptionFieldTemplate}}

The caption of the current tiddler is “Transclude the current tiddler through a template”.

Transclude a tiddler with parameters
{{Sn:WikitextParameterTransclusion|param1|param2}}

(This one can't be shown as a live example because the live example code loses the parameters before they can be passed on.)

Transclude the result of a filter

{{{ [all[tiddlers+shadows]!is[system]tag[Template]] }}}

Transclude the result of a filter through a template

{{{ [all[tiddlers+shadows]tag[Exercise]first[]] || Sn:BoldfaceTemplate }}}

Place the ContactInformationTemplate on all of the contacts in your wiki.

(You may be wondering if there's a way to avoid even the repetition of adding the reference to the template to all your tiddlers. The answer is yes, and we'll be getting there in a couple chapters.)

Transclude the value of a variable

<$let myvariable="Hello!">
  <<myvariable>>
</$let>

Hello!

Call a procedure

\procedure myproc(myName) Hi <<myName>>!

<<myproc Soren>>

Hi Soren!

Transclude the result of the first item in a filter expression returned by a function

\function add.numLetters(myName) [<myName>split[]count[]addsuffix[ letters)]addprefix[ (]addprefix<myName>]

<<add.numLetters "Alice">>

Alice (5 letters)

Call a function within a filter expression using the function operator

\function add.numLetters(myName) [<myName>split[]count[]addsuffix[ letters)]addprefix[ (]addprefix<myName>]

{{{ [function[add.numLetters],[Bob]] }}}

Call a function within a filter expression as an operator (requires the function to have a . in its name)

\function add.numLetters(myName) [<myName>split[]count[]addsuffix[ letters)]addprefix[ (]addprefix<myName>]

{{{ [add.numLetters[Charlie]] }}}

Call a macro (transcluding its result), treating its parameter as a variable

\define mymacro(myName) Hi <<__myName__>>!

<<mymacro Soren>>

Hi Soren!

Call a macro (transcluding its result), using its parameter in text substitution

\define mymacro(myName) Hi $myName$!

<<mymacro Soren>>

Hi Soren!

Include the value of a variable in a macro via text substitution

\define wikipediaLink() https://en.wikipedia.org/wiki/$(articleName)$

<$let articleName="TiddlyWiki">
  <<wikipediaLink>>
</$let>