Template:Qif
From Wikipedia, the free encyclopedia
This page is currently inactive and is retained for historical reference. This template was replaced by {{#if}}, which should be used instead. Its original code is below. |
{{{else{{{test|}}}|{{{test{{{test|}}}|{{{then|}}}}}}}}}
This template may have no transclusions, because it is substituted by a tool or script, it is used as part of a short-term or less active Wikipedia process, or for some other reason. |
Template:Qif formerly implemented an "if" function, which is now implemented by the parser function {{#if}}.
Purpose and function
Provides if then else functionality.
- Parameter else is optional.
- This template has undefined behaviour, if parameter test or then (or both) are missing.
- This template also has undefined behaviour, if any parameter (be it named or unnamed) that is different from test, then or else is defined when calling the template.
Note that {{qif}}
does not work when subst'ed (like {{ifndef}}
, the then part alone as in {{ifdef}}
can be substituted).
Of course it's impossible to use vertical bars in parameter values directly, use either |
or Template:! - the latter is only relevant for wiki table delimiters.
Wikipedia CTO Brion Vibber expressed support to implement the functionality of qif into MediaWiki; this became {{#if}}.
Usage
{{Qif
|test=VARIABLE_OR_PARAMETER_TO_TEST
|then=code if 'test' is not empty
|else=code if 'test' is empty
}}
Parameter else is optional. So this was also possible:
{{Qif
|test=VARIABLE_OR_PARAMETER_TO_TEST
|then=code if 'test' is not empty
}}
Examples
More information Code, Result ...
Code | Result |
---|---|
{{Qif
|test={{boolne|foo|bar}}
|then=true
|else=false
}}
|
true |
{{Qif
|test={{booleq|foo|bar}}
|then=true
|else=false
}}
|
false |
{{Qif
|test=
|then=bar
}}
|
|
{{Qif
|test=foo
|then=bar
}}
|
bar |
Close
See also
- Template:Switch(edit talk links history)
- Template:If (edit · talk · links · history) at Meta explains "undefined" cases
- Template:Ifdef (edit · talk · links · history) at Meta allows substitution
- Category:If-then-else templates
- Help:Conditional tables
- ParserFunctions
The above documentation is transcluded from Template:Qif/doc. (edit | history)
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this template.
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this template.