Help:Parameter default
Limitation
In the case of multiple default parts, only the first applies: [a|b|c|d] is equivalent with [a|b]. The default part can only contain "|" as part of full template, parameter or link syntax within it, and within nowiki-tags. Note that "|" can be avoided in table syntax by applying HTML coding (element "<table>").
The expression for the parameter name can also contain "|", as part of full template or parameter syntax within it.
Examples, using Template:x3 containing "<noinclude>{{Please leave this line alone (template sandbox heading)}}<!--
* Welcome to the template sandbox! *
* Please leave this part alone *
* The page is cleared regularly *
* Feel free to try your editing skills below *
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■--></noinclude>
"
and Template:t2 containing "[[w:List of people by name: {{{1}}}{{{2}}}|{{{1}}}{{{2}}}]]<noinclude>[[Category:Help:Templates templates]]</noinclude>
":
- {{{a|b|c|d}}} gives b
- {{{a|{{x3|b}}}}} gives
- {{{a|{{{b|c}}}}}} gives c
- {{{a|[[b|c]]}}} gives c
- {{{{{x3|a}}|b}}} gives b - parameter aaa is undefined
- {{{{{{a|b}}}|c}}} gives c - parameter b is undefined
- {{{a|<nowiki>b|c</nowiki>}}} gives b|c - works fine for rendering text, but is not suitable for putting parameters b and c in a template call (there is no function for removing nowiki tags):
- {{t2|{{{a|<nowiki>b|c</nowiki>}}}}} gives [[w:List of people by name: b|c{{{2}}}|b|c{{{2}}}]]
Repetition
A "for-loop" is achieved using
m:Template:fors (backlinks edit), containing:
{{fors/aux |v@= |c={{{call}}} |pv={{{pv|1}}} |s={{{sep|}}} |pc1={{{pc1|=}}} |pc2={{{pc2|=}}} |pc3={{{pc3|=}}} |pc4={{{pc4|=}}}| 1={{{1|@}}}|2={{{2|@}}}|3={{{3|@}}} }}
with m:Template:fors/aux (backlinks edit), containing:
{{{v{{{1}}}|{{{{{c}}}|{{{pc1}}}|{{{pc2}}}|{{{pc3}}}|{{{pc4}}}|{{{pv}}}={{{1}}}}}}}} {{{v{{{2}}}|{{{s}}}{{{{{c}}}|{{{pc1}}}|{{{pc2}}}|{{{pc3}}}|{{{pc4}}}|{{{pv}}}={{{2}}}}}}}} {{{v{{{3}}}|{{{s}}}{{{{{c}}}|{{{pc1}}}|{{{pc2}}}|{{{pc3}}}|{{{pc4}}}|{{{pv}}}={{{3}}}}}}}}
In short form the latter consists of components
[ v[i] | [s] {{[c]|[pc1]|[pc2]|[pc3]|[pc4]|[pv]=[i]}} ]
(i = 1, 2, 3, for i = 1 without [s])
or in terms of the parameters of the first template:
[v[i|@] | [sep|] {{[call]|[pc1|]|[pc2|]|[pc3|]|[pc4|]|[pv|1]=[i]}} ]
This is indeed of the above-mentioned form [a[b|c]|f([b])], with a=v, b=i, c=@, and
f(x) = [sep|] {{[call]|[pc1|]|[pc2|]|[pc3|]|[pc4|]|[pv|1]=x}}
The assumptions mentioned above apply for d equal to null, and provided that no [i] is equal to "@".
Variations
Since v@=null we can also take make the concatenation the outer operation:
[v[i|@] | [sep|]] [v[i|@] | {{[call]|[pc1|]|[pc2|]|[pc3|]|[pc4|]|[pv|1]=[i]}} ]