Template talk:Qif
From Hattrick
Purpose and Function
- This is an implementation of the "if ... then ... else" behaviour, to be used mostly in other Templates.
- This function has undefined behaviour if parameter test or then is missing, or there are additional parameters defined. Parameter else is optional.
- This is basically the same as the Wikipedia template [1], please check the discussion page on the wikipedia for more information.
Usage
{{qif
|test=VARIABLE_OR_PARAMETER_TO_TEST
|then=code if true or empty
|else=code if true or empty
}}
Example
| Code | Result |
|---|---|
{{qif
|test={{boolnot|true}}
|then=true
|else=false
}}
|
false |
{{qif
|test={{booleq|foo|bar}}
|then=true
|else=false
}}
|
true |
{{qif
|test=
|then=bar
}}
|
|
{{qif
|test=foo
|then=bar
}}
|
Comments
Ok, let's see if this works. It can be useful in some templates (for hiding empty fields, or similar) --duno7 15:24, 28 November 2005 (UTC)