Brief macro docs

This commit is contained in:
Jeremy Ruston 2013-03-12 19:00:42 +00:00
parent 193d073906
commit b0526ad306
1 changed files with 31 additions and 0 deletions

View File

@ -187,6 +187,37 @@ You can include a horizontal rule with three or more dashes on their own on a li
---
">>
! Macros
Macros are snippets of text that can be inserted with a concise shortcut. A macro is defined like this:
```
\define mysamplemacro(name:"Bugs Bunny",address:"Rabbit Hole Hill")
Hi, I'm $name$ and I live in $address$
\end
```
The first line of the definition specifies the macro name and any parameters. Parameters are named and can optionally have default values that are used if the parameter isn't specified at the time of calling. The body of the macro definition follows, terminated with `\end`. The macro can include parameters using the `$name$` construction.
Macro definitions must be placed at the top of a tiddler. Macros are available to the tiddler that defines them, plus any tiddlers that it transcludes.
Macros are used like this:
```
<<mysamplemacro>>
<<mysamplemacro "Donald Duck">>
<<mysamplemacro "Mickey Mouse" "Mouse House">>
```
Resulting in:
```
Hi I'm Bugs Bunny and I live in Rabbit Hole Hill
Hi I'm Donald Duck and I live in Rabbit Hole Hill
Hi I'm Mickey Mouse and I live in Mouse House
```
! HTML in WikiText
HTML tags and comments can be used directly in WikiText. For example: