Template:If

From Iron Chariots Wiki
Revision as of 15:35, 28 June 2007 by Dcljr (Talk | contribs)
Jump to: navigation, search

Description

See also WikimediaMeta:Template:If.
  • If the value of test is non-empty ("true"), then: if the value of then is defined, that value is produced, otherwise the empty string.
  • If the value of test is empty ("false"), then: if the value of else is defined, that value is produced, otherwise the empty string.
  • If the value of test is undefined:
    • if the value of else is defined, that value is produced.
    • if the value of else is also undefined, then: if the value of then is defined, that value is produced, otherwise the empty string.

Note that the rules for the case that the value of test is undefined are somewhat arbitrary, and just a by-product of the code. Note in particular that in this case it makes a difference whether the value of else is empty or undefined, see the examples below.

Examples

Overview of all 12 cases:

Code Result
{{If|test=1|then=a|else=b}} a
{{If|test=|then=a|else=b}} b
{{If|test=1|then=a}} a
{{If|test=|then=a}}
{{If|test=1|else=b}}
{{If|test=|else=b}} b
{{If|test=1}}
{{If|test=}}
{{If|then=a|else=b}} b
{{If|then=a}} a
{{If|else=b}} b
{{If}}
Personal tools
Namespaces
Variants
Actions
wiki navigation
IronChariots.Org
Toolbox