Help:Parameter default

Note: Information on this page relates to MediaWiki versions 1.6 and later.

Notation: on this page the wikitext is written as [a].

In a template, [a|b] is equal to [a] if that is defined, and else equal to b.

These results [a] and b can be end results, but they can also be parameter names, parameter values, template names, parts thereof, etc.

If the results are template names as part of template calls involving a parameter of the outer template which may be undefined, one can arrange that an inner template is called with a parameter depending on an undefined outer parameter only if the parameter concerned is not actually used in the inner template, e.g. dummy template can be called as  even if [a] is undefined, see e.g..

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 " (i = 1, 2, 3, for i = 1 without [s])

or in terms of the parameters of the first template:

This is indeed of the above-mentioned form [a[b|c]|f([b])], with a=v, b=i, c=@, and

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:

Conditional statement
contains:

or in short form:

[ else[test|] | [ test[test|] | [then|] ] ]

If [test] is defined this reduces to

[ else[test] | [ test[test] | [then|] ] ]

For test equal to null this reduces to [else|]; otherwise, if no parameter name starting with "test" or "else" applies except these themselves, then this reduces to [then|].

If [test] is undefined we get

[ else | [then|] ]

Server efficiency
Parameter default constructs are said to be more efficiently executed by the server than similar constructs using extra layers of templates.