Skip to content
EntityQ5902486· pop 221

Template:If empty

Sign in to save

Wikimedia template

~2 min read

Article

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.

Categories