Skip to content
EntityQ5902486· pop 221

Template:If empty

Sign in to save

Wikimedia template

In the Vinony graph

It is catalogued under topics including If-then-else templates, Lua-based templates and Parameter selection templates.

Its subject is documented across 185 Wikipedia language editions.

Wikidata facts

via Wikidata · CC0

~2 min read

Encyclopedic overview

Template documentation view] [edit] [history] [purge]

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.

Excerpted from Wikipedia’s “Template:If empty” article, available under the CC BY-SA 4.0 licence.

Categories