Template:Ifparadef full/doc

This is the ifparadef full 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 five unnamed parameters.
 * Standard functionality:
 * Extended functionality:

The parameter to be tested is fed twice, as the first two parameters. For the template to be able to detect undefined input, the two inputs must have fall-back values. Typical usage is to use "x" and "y" as fall-back values (e.g. ). The two fall-back values must be different, so feeding "x" and "x" doesn't work, but "a" and "b" works. Or one of the fall-back values can be left empty, as in "x" and "". The fall-back values can be any character or even a string. For example, all of the following are valid uses:

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

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

The fifth 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 of the second parameter are used as long as the tested parameter is defined.

Note that feeding an empty but defined string to the fifth parameter means the extended test still is done, and if the tested input is defined and empty then this template returns an empty string. Like this:



Likewise empty strings can be fed to parameters 3 and 4 if you don't want any output in those cases. Like this:



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: