Using #ifeq can compare 2 strings or numbers, but #ifexpr can check a math formula or multiple conditions. The #switch function can branch to dozens or hundreds of different paths depending on a value, to act as a case statement to choose among alternatives. Using #if can check to see if a parameter has been passed, or if an expression evaluates as true. Using #iferror can check to see if an expression value triggers an error else shows the value, while #ifexist can check to see if a page name or image/media file exists yet.

Note that all extra white space within the outer braces gets stripped out, so this permits formatting these constructs for better readability. For example:

The magic words can be used together, in nested combinations, to branch on complex conditions. Some combinations can use tricks based on the interactions between them.

Note that with #if expressions, using a parameter in the form "{{{1}}}" always requires a final bar/pipe "|" in the parameter: {{{1|}}}. If the bar/pipe is omitted, then whenever the parameter 1 is absent, instead of leaving the field blank, the page will use the literal text "{{{1}}}" (as 3 sets of curly braces around a "1"), and the #if will be true unless parameter 1 is passed as an empty string, such as "1=".

So, when checking the value of a parameter named "{{{catname}}}" then the function {{lc:___}} can be used to instantly convert to lowercase text, during the comparison. The value of {{{catname}}} will not be changed for later use, instead it is only compared as lowercase letters.

Using #ifexpr can check a math formula or multiple conditions.
The parser function #ifexpr evaluates a mathematical or boolean expression and branches depending on the boolean true/false value of the result (where zero means false):

An invalid or wrong input expression will trigger the true-value part (an error message is treated as an ordinary string; it is not equal to zero, so we get value if false).

{{#ifexpr: = | yes | no }} → Expression error: Unexpected = operator

{{#ifeq: {{#expr: = }} |0 | yes | no }} → no

Either or both of the return values may be omitted; no output is given when the appropriate branch is left empty:

{{#ifexpr: 1 > 0 | yes }} → yes

{{#ifexpr: 0 = 0 | yes }} → yes

{{#ifexpr: 1 > 0 | | no}} →

Tip

To check comparisons based on dates (If current date and time is after some other date and time), first convert the time to number of seconds after January 1, 1970 using function {{#time: U }}, then simply add and subtract dates.

The #switch function can branch to dozens or hundreds of different paths depending on a value, to act as a case statement which chooses among alternatives. A #switch expression is a quick way to handle multiple code values for a parameter; however, the performance slows when more than 100 branches, and common values should be listed higher among the choices, to run 3x-8x faster. In rare cases, a #switch could have over two thousand branches, but it takes time just to scan all the branches, even before comparing the values.