mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 12:07:19 +00:00
Docs: tweaks to 'Macro Definitions in WikiText'
This commit is contained in:
parent
9a2e2cd385
commit
ee28f66b0a
@ -1,13 +1,13 @@
|
||||
caption: Macro Definitions
|
||||
created: 20150220181617000
|
||||
modified: 20171215152754837
|
||||
modified: 20180820165115455
|
||||
tags: WikiText
|
||||
title: Macro Definitions in WikiText
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
A [[macro|Macros]] is defined using a `\define` [[pragma|Pragma]]. Like any pragma, this can only appear at the start of a tiddler.
|
||||
|
||||
The first line of the definition specifies the macro name and any parameters. Each parameter has a name and, optionally, a default value that is used if no value is supplied on a particular call to the macro. The lines that follow contain the macro's text (i.e. the snippet represented by the macro name), until `\end` appears on a line by itself:
|
||||
The first line of the definition specifies the macro name and any parameters. Each parameter has a name and, optionally, a default value that is used if no value is supplied on a particular call to the macro. The lines that follow contain the text of the macro text (i.e. the snippet represented by the macro name), until `\end` appears on a line by itself:
|
||||
|
||||
<$codeblock code={{$:/editions/tw5.com/macro-examples/say-hi}}/>
|
||||
|
||||
@ -20,20 +20,21 @@ Alternatively, the entire definition can be presented on a single line without a
|
||||
A more formal [[presentation|Macro Definition Syntax]] of this syntax is also available.
|
||||
|
||||
!! Accessing variables and parameters
|
||||
Inside the macro there are a few methods for accessing variables and parameters defined outside of the macro or in the macro parameter list.
|
||||
|
||||
Inside the macro there are several methods for accessing variables defined outside of the macro or parameters from the macro parameter list.
|
||||
|
||||
|syntax|description|h
|
||||
|`$...$`|parameter defined in the macro parameters list|
|
||||
|`<<__...__>>`|parameter defined in the macro parameters list but the syntax evaluates the parameter as it is invoked|
|
||||
|`$(...)$`|variable placeholder to variable defined outside of the macro|
|
||||
|`<<...>>`|variable invocation of variable (or other macro) defined outside of the macro|
|
||||
|`$...$`|Text substitution of a parameter defined in the macro parameters list |
|
||||
|`<<__...__>>`|Parameter-as-variable access to a parameter defined in the macro parameters list |
|
||||
|`$(...)$`|Text substitution of a variable defined outside of the macro |
|
||||
|`<<...>>`|Access to a variable (or other macro) defined outside of the macro |
|
||||
<br>
|
||||
|
||||
!!! Placeholders `$(...)$`
|
||||
|
||||
The macro can contain placeholders for parameters. These consist of a parameter name between dollar signs, like `$this$`.
|
||||
|
||||
It can also contain placeholders for [[variables|Variables]]. These consist of a variable name (or macro name) between dollar signs and round brackets, like `$(this)$`.
|
||||
The macro can also contain placeholders for [[variables|Variables]]. These consist of a variable name (or macro name) between dollar signs and round brackets, like `$(this)$`.
|
||||
|
||||
The actual value of the parameter or variable is substituted for the placeholder whenever the macro is called:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user