19th June 2024 at 9:17pm
Invoked in normal wikitext context: <$transclude $variable=myvar/>
or <<myvar>>
how declared | behaviour |
---|---|
\define | All wikitext and variable substitution and textual substitution takes place |
$set , $let , $vars , \procedure, \widget | All wikitext and variable substitution takes place |
\function | Invoking a function in this way (<<.myfun>> ) is a synonym for <$text text={{{[function[.myfun]]}}}/> . As with any filtered transclusion (i.e. triple curly braces), all results except the first are discarded |
Invoked via widget attribute: <div class=<<myvar>>/>
how declared | behaviour |
---|---|
\define | Textual substitution of parameters is performed on the body text. No further processing takes place. The result after textual substitution is used as the attribute's value |
$set , $let , $vars , \procedure, \widget | Body text is retrieved as-is and used as the attribute's value. |
\function | When a function (e.g. .myfun ) is invoked as <div class=<<.myfun>>/> , it is a synonym for <div class={{{[function[.myfun]]}}}/> . As with any filtered transclusion (i.e. triple curly braces), all results except the first are discarded. That first result is used as the attribute's value. Note that functions are recursively processed even when invoked in this form. In other words a filter expression in a function can invoke another function and the processing will continue |
Invoked via filter operator parameter: [<myvar>]
how declared | behaviour |
---|---|
\define | Textual substitution of parameters is performed on the body text. No further processing takes place. The result after textual substitution is used as the filter operator's parameter. |
$set , $let , $vars , \procedure, \widget | Body text is retrieved as-is and used as the filter operator's parameter. |
\function | The body text of the function is treated as a filter expression and evaluated. The first result is passed to the operator as a parameter. The remaining results are discarded. |
Invoked via function call in a filter expression: [function[.myfun]]
how declared | behaviour |
---|---|
\define, $set , $let , $vars , \procedure, \widget | Every function is a variable, but only variables defined using \function are invokable using the function filter operator. Attempts to use a non-function variable is the same as if the function doesn't exist. The behavior in this case is like the identity function. All filter input is passed unchanged to the output. |
\function | The body text of the function is treated as a filter expression and evaluated. This filter expression can itself contain a function call. Filter expressions can be factored out into functions arbitrarily deep. |
Examples
Below is an example macro, procedure and function definition. All three forms of parameter substitution $a1$
, <<__a1__>>
, and <<a1>>
are included in each definition. The output helps illustrate when each form of substitution will or will not have affect.
\define m1(a1) $a1$ - <<__a1__>> - <<a1>>
\procedure p1(a1) $a1$ - <<__a1__>> - <<a1>>
\function f1(a1) $a1$ "-" [<__a1__>] ="-" [<a1>] :and[join[ ]]
Variable transclusion | output |
---|---|
<<m1 foo>> | foo - foo - |
<<p1 foo>> | $a1$ - - foo |
<<f1 foo>> | $a1$ - - foo |
Widget attribute | output |
<$text text=<<m1 foo>>/> | foo - <<__a1__>> - <<a1>> |
<$text text=<<p1 foo>>/> | $a1$ - <<__a1__>> - <<a1>> |
<$text text=<<f1 foo>>/> | $a1$ - - foo |
Filter operator parameter | output |
[<m1 foo>] | foo - <<__a1__>> - <<a1>> |
[<p1 foo>] | $a1$ - <<__a1__>> - <<a1>> |
[<f1 foo>] | $a1$ - - foo |
Function call in filter expression | output |
[function[m1],[foo]] | "A free, open source wiki revisited" by Mark Gibbs, NetworkWorld |
[function[p1],[foo]] | "A free, open source wiki revisited" by Mark Gibbs, NetworkWorld |
[function[f1],[foo]] | $a1$ - - foo |