Template:If empty
{{#invoke:If empty|main}}
|
[edit] []
Template:Template redirects Template:Lua
This is the {{If empty}} template.
This template is used inside other templates. It takes any number of parameters 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, image and picture that is defined and non-empty, otherwise "default.svg". ContentsRationale[edit]The MediaWiki parameter default function doesn't return the default value for empty parameters. That is, The usual workaround for a single parameter is:
But this becomes complex when several parameters are to be checked:
In these cases, {{if empty}} produces the simpler syntax (as above):
Piping[edit]Parameters used with {{if empty}} must be piped – i.e. include the vertical bar (pipe) symbol ("Template:Thinsp|Template:Thinsp") as a trailing character – so that empty or undefined parameters aren't treated as text and returned incorrectly. Hence, for example, Examples[edit]See also[edit]
|