Revision as of 03:03, 22 July 2008

The documentation for this template is transcluded from Template:If/doc. Please edit that page if you want to change something in the documentation. Do not edit this page unless you know what you're doing.

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 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 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.