Template:If either/doc

From blackwiki
< Template:If either
Revision as of 11:07, 9 July 2014 by imported>Sardanaphalus (replaced/corrected <tt>, corrected example, some formatting)
Jump to navigation Jump to search

This helper template is designed to be used in other templates. It can help editors create template code that or self documenting. The major advantage of using this template over using the construct {{#if:{{{1|}}}{{{2|}}} |...}} is that if the first parameter is not empty then the second parameter is not evaluated.

It can also be used to replace the construct {{#if:a |true |{{#if:b |true |false}} }}  (i.e. "if a, then true; else if b, then true; else false").

Syntax and interpretation

{{if either |a |b |output if (a or b) true |output if (a or b) false}}

The "or" in "a or b" is inclusive: if both a and b are true, the template will return the first output (output if ... true).

Examples

{{if either |a |b |true |false}} → true

{{if either |a | |true |false}} → true

{{if either | |b |true |false}} → true

{{if either | | |true |false}} → false

See also