A conditional template, which uses named parameters to select from two or more alternatives:

{{qif|<test=>|<then=>|<else=>}}

When used in this manner, "qif" functions just like {{if}}: when the test parameter is an empty string, the value of else is displayed. Otherwise, the value of then is displayed. Unlike {{if}}, however, you must use named parameters (test=, then=, else=).

However, you can also use it as you would a "switch" or "select" statement. For example:

{{qif|<test=>|<testeven=>|<testodd=>}}

Here, if the result of test is the string "even", then the contents of testeven are displayed. If the result is "odd", the contents of testodd are displayed. Any other value produces no output at all. This can be used to select from any number of possible results.

How it works: The template first tries to display a parameter with the name is "else" followed by the contents of the test parameter. If no such parameter exists, it tries again with "test" followed by the contents of the test parameter. Finally, if neither exists, the value of then is displayed.


Sauf mention contraire, le contenu de la communauté est disponible sous licence CC-BY-SA .