Help:Macro
From QED
The #macro parser function is intended for use in templates in which template variables must be expanded before XML-style tags are processed.
Syntax
{{#macro:TAGNAME|TEXT}}
- or
{{#macro:TAGNAME|ASSIGNMENTS|TEXT}}
The effect is as though <TAGNAME ASSIGNMENTS>TEXT</TAGNAME> had been specified after any template variables in TAGNAME and ASSIGNMENTS had been expanded.
Example
On QED, <image> is defined as an XML-style tag (see QED:image). If template variables were expanded before such tags, we would be able to write expressions such as:
<image src={{{1}}} width={{{width|{{{3|450}}}}}}>{{{2|}}}</image>
To achieve the intended effect, we would instead write:
{{#macro:image|src={{{1}}}
width={{{width|{{{3|450}}}}}}
| {{{2|}}} }}
This is in fact how Template:Transclude is defined.
Notes
Prior to MediaWiki version 1.12, template variables were processed before XML-style extensions.












