Template:If/doc


 * Usage
 * test&#61;test string
 * (other cases, in which some parameters are missing, are shown below)


 * Purpose
 * Provides simple if-then-else capability in templates.


 * Examples


 * Technical description
 * In what follows, a "non-empty" string is one containing at least one non-whitespace character; an "empty" string contains no non-whitespace characters (thus, either no characters at all or only whitespace characters). Note in particular that mathematical or "logical" expressions, such as "0" or "FALSE" will evaluate as "true", since they are non-empty strings. See also WikimediaMeta:Template talk:Ifold.
 * 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, then:
 * 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 in which the value of test</tt> 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</tt> is empty or undefined; see the examples above.


 * Warning to editors
 * This template is used in other templates that are widely used in articles on this wiki. In addition, it relies on advanced template techniques. Don't edit it unless you really know what you're doing. If you just want to change something in this documentation, edit Template:If/doc, instead.