diff --git a/editions/tw5.com/tiddlers/wikitext/Macro Definitions in WikiText.tid b/editions/tw5.com/tiddlers/wikitext/Macro Definitions in WikiText.tid index d5c7ce509..cae2b2009 100644 --- a/editions/tw5.com/tiddlers/wikitext/Macro Definitions in WikiText.tid +++ b/editions/tw5.com/tiddlers/wikitext/Macro Definitions in WikiText.tid @@ -1,6 +1,6 @@ caption: Macro Definitions created: 20150220181617000 -modified: 20221022135909352 +modified: 20221207094236472 tags: WikiText title: Macro Definitions in WikiText type: text/vnd.tiddlywiki @@ -19,22 +19,6 @@ Alternatively, the entire definition can be presented on a single line without a \define sayhi(name:"Bugs Bunny") Hi, I'm $name$. ``` -Macro definitions can be nested by specifying the name of the macro in the `\end` marker. For example: - -< -\end actions -<$button actions=<>> -$caption$ - -\end special-button - -<> -""">> - -A more formal [[presentation|Macro Definition Syntax]] of this syntax is also available. - !! Accessing variables and parameters Inside the macro there are several methods for accessing variables defined outside of the macro or parameters from the macro parameter list. @@ -93,3 +77,26 @@ To make a macro available to all tiddlers, define it in a tiddler that has the t It is also possible to write a macro as a [[JavaScript module|https://tiddlywiki.com/dev/index.html#JavaScript%20Macros]]. ~JavaScript macros are available to all tiddlers, and offer the maximum flexibility. A tiddler can manually import macro definitions from a [[selection|Title Selection]] of other tiddlers by using the <<.wlink ImportVariablesWidget>> widget. + +!! Nested Macro Definitions + +Macro definitions can be nested to any number of required levels by specifying the name of the macro in the `\end` marker. Nested macro definitions must appear at the start of the definition that contains them. For example: + +< +\end actions +<$button actions=<>> +$caption$ + +\end special-button + +<> +""">> + +Note that the textual substitution of macro parameters that occurs when the outer macro is rendered will apply to the nested definitions as well. That generally means that textual substitution of macro parameters should not be used within nested macros. + +Parameters of nested macros can also be accessed via the `<<__variablename__>>` syntax. As ordinary variables, these parameters are available within nested child macros (and grandchildren etc). + +A more formal [[presentation|Macro Definition Syntax]] of this syntax is also available. +