Template:Ifparadef/doc

This is the ifparadef meta-template.

This template is used to test if a parameter is defined; thus, it should only be directly used on other templates.

Usage
This template accepts up to four unnamed parameters.
 * Standard functionality:
 * Extended functionality:

The first parameter, which is required, is the name of the parameter to be tested. It must be formatted as, with the "¬", otherwise the template will not work correctly (see the Examples section below for examples with and without the "¬").

The second parameter is the text to display if the tested parameter is defined. If the fourth parameter is also used, the second parameter is the text displayed when the tested parameter is defined and not empty.

The third parameter is the text to display if the tested parameter is not defined.

The fourth parameter is the text to display if the tested parameter is defined and empty (or if it contains only whitespace). If this parameter is omitted, only one defined test is performed, and the contents (or default) of the second parameter are used as long as the tested parameter is defined.

This template uses "¬" to test for a defined parameter; the template cannot detect when a literal "¬" is passed as input from a final deployment (such as an article) and will give incorrect results in such cases. If you need to handle that case too, then see ifparadef full.

Hardcoding
An alternative to using this meta-template is to hardcode this functionality in your template. Here are code for the standard and the extended functionality:

For code that works with any input (detects "¬" as defined, not empty), see Template:Ifparadef full.