Template:Qif/doc

From ISFDB
< Template:Qif
Revision as of 16:30, 21 October 2008 by DESiegel60 (talk | contribs) (doc page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 &#124; or Template:! - the latter is only relevant for Wiki table delimiters.

Wikipedia CTO Brion VIBBER has expressed support to implement the functionality of qif into MediaWiki. So qif should not be viewed as definitive solution.

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 you may also do:

{{qif
  |test=VARIABLE_OR_PARAMETER_TO_TEST
  |then=code if 'test' is not empty
}}

Example

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


Source

This documentation (or its inital version, it may have been edited here since) is copied from Wikipedia:Template talk:Qif, under the GNU Free documentation licensce (which all wikipedia text is released under). See that page amnt it's archives for related information and caveats.