This is a documentation subpage for Template:If empty. It may contain usage information, categories and other content that is not part of the original template page. |
This template can only be edited by administrators because it is transcluded onto one or more cascade-protected pages. |
This template is used in system messages, and on approximately 3,930,000 pages, or roughly 6% of all pages. Changes to it can cause immediate changes to the Wikipedia user interface. To avoid major disruption and server load, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them. Preview message: Transclusion count updated automatically (see documentation). |
This template uses Lua: |
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. By writing {{if empty|a|b|c}}
instead of {{#if:a|a|{{#if:b|b|c}}}}
, expression a and b do not have to be repeated and evaluated twice. The template provides a fallback order, similar to a try catch based "It is easier to ask for forgiveness than permission" (EAFP) programming style.
Typical usage is like this:
{{If empty |{{{logo|}}} |{{{image|}}} |{{{picture|}}} |default.svg}}
This returns the first of the parameters logo, image and picture that is defined and non-empty, otherwise "default.svg".