Template:If empty/doc

This is the if empty template.

This template is used inside other templates. It takes up to nine parameters (unnamed parameters 1-9) and returns the first found to be defined and non-empty. If none is found, nothing is returned. Typical usage is like this:

This returns the first of the parameters logo and image that is defined and non-empty, otherwise "default.svg".

Rationale
The MediaWiki parameter default function doesn't return the default value for empty parameters. That is,  does not return "default.svg" if the template was called like this:.

The usual workaround for a single parameter is:

But this becomes complex when several parameters are to be checked:

In these cases, produces the simpler syntax above:

Piping
Parameters used with must be piped – i.e. include the vertical bar (pipe) symbol ("&#123;") as a trailing character – so that empty or undefined parameters aren't treated as text and returned incorrectly. Hence, for example,, and  rather than ,  and  in the above examples.