Link
Other languages: Template:ParserFunctions Template:H:h Template:Sspp Template:Shortcut Template:Move Template:Extension
The MediaWiki extension ParserFunctions is a collection of parser functions (note the difference between the name of the collection, and the general term). These parser functions have a hash character in front of the function name, so they typically have the syntax:
Contents
Functions
The extension defines nine functions: expr, if, ifeq, ifexist, ifexpr, switch, time, rel2abs, and titleparts.
#expr:
- syntax: Template:Ft
#if:
- syntax:
The if
function is an if-then-else construct. The condition is always true unless it is empty or whitespace-only. The code in the second argument is parsed if the condition is true, and the third argument is parsed if the condition is false (either or both may be blank, and the code-if-false argument can be omitted entirely).
The condition is evaluated as text, so mathematical expressions will always evaluate as true; to use expressions as conditions, see #ifexpr. It is not possible to distinguish between an undefined parameter in a template and a blank one (it is possible with #ifexpr).
Examples:
- Template:Ft = {{#if:foo| do if true | do if false}}
- Template:Ft = {{#if:0 | do if true | do if false}}
- Template:Ft = {{#if: | do if true | do if false}}
#ifeq:
- syntax: