This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

ParametersWidget (Examples)

18th May 2023 at 1:51pm

Example i: Shows transclusion of Sample Tiddler Template. The template tiddler has two parameters name and age and here their default values are used.

<$transclude $tiddler="Sample Tiddler Template" />

Example ii: Shows, another transclusion of Sample Tiddler Template, here the value of age is passed, but name uses its default value.

<$transclude $tiddler="Sample Tiddler Template" age=33/>

Example iii: Shows, another transclusion of Sample Tiddler Template, here the value of both name and age are passed.

<$transclude $tiddler="Sample Tiddler Template" age=45 name="Jeremy Ruston" />

In the simple form the above transclusion is equivalent to

{{Sample Tiddler Template|Jeremy Ruston|45}}

In this simple form, parameters passed by position not by name. So the first value is passed to the first parameter, here name and the second value is passed to the second parameter, here age.

Remarks

  1. Passing parameter by name is good practice and is recommended for clarity. So for parameterized transclusions, the use of $transclude is recommended over simple form transclusion.
  2. When passing parameters value by position, you cannot pass the second parameter while the first one has not been passed.

Example iv: Here the $parameters widget is used to declare a parameter whose default value is transcluded from another tiddler.

\procedure myproc()
<$parameters name={{$:/SiteTitle}} age="21">
My name is <<name>> and my age is <<age>>.
</$parameters>
\end

<$transclude $variable="myproc" age="19"/>