<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.thegoonshow.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=Template%3AIf_empty%2Fdoc</id>
	<title>Template:If empty/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.thegoonshow.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=Template%3AIf_empty%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Template:If_empty/doc&amp;action=history"/>
	<updated>2026-05-14T09:29:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://www.thegoonshow.co.uk/wiki/index.php?title=Template:If_empty/doc&amp;diff=362&amp;oldid=prev</id>
		<title>Kurt at 15:18, 20 July 2022</title>
		<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Template:If_empty/doc&amp;diff=362&amp;oldid=prev"/>
		<updated>2022-07-20T15:18:41Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:18, 20 July 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Template redirect |Ifempty |First nonempty |Use first nonempty |Firstdata}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Template redirect |Ifempty |First nonempty |Use first nonempty |Firstdata}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Lua|Module:If empty}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Lua|Module:If empty}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{High-use|all-pages = yes}}&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;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 &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty|a|b|c}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#if:a|a|{{#if:b|b|c}}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, expression a and b do not have to be [[Don't repeat yourself|repeated]] and evaluated twice. The template provides a [[fallback]] order, similar to a [[try catch]] based &amp;quot;It is easier to ask for forgiveness than permission&amp;quot; ([[EAFP]]) programming style.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;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 &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty|a|b|c}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#if:a|a|{{#if:b|b|c}}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, expression a and b do not have to be [[Don't repeat yourself|repeated]] and evaluated twice. The template provides a [[fallback]] order, similar to a [[try catch]] based &amp;quot;It is easier to ask for forgiveness than permission&amp;quot; ([[EAFP]]) programming style.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kurt</name></author>
	</entry>
	<entry>
		<id>https://www.thegoonshow.co.uk/wiki/index.php?title=Template:If_empty/doc&amp;diff=361&amp;oldid=prev</id>
		<title>Kurt: Created page with &quot;{{Documentation subpage}} &lt;!----PLEASE ADD TEMPLATE CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE----&gt; {{Template redirect |Ifempty |First nonempty |Use first nonempty |Firstdata}} {{Lua|Module:If empty}} {{High-use|all-pages = yes}}  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 &lt;code&gt;&lt;nowiki&gt;{{if empty|a|b|c}}&lt;/nowiki&gt;&lt;/co...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Template:If_empty/doc&amp;diff=361&amp;oldid=prev"/>
		<updated>2022-07-20T15:18:06Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Documentation subpage}} &amp;lt;!----PLEASE ADD TEMPLATE CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE----&amp;gt; {{Template redirect |Ifempty |First nonempty |Use first nonempty |Firstdata}} {{Lua|Module:If empty}} {{High-use|all-pages = yes}}  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 &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty|a|b|c}}&amp;lt;/nowiki&amp;gt;&amp;lt;/co...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Documentation subpage}}&lt;br /&gt;
&amp;lt;!----PLEASE ADD TEMPLATE CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE----&amp;gt;&lt;br /&gt;
{{Template redirect |Ifempty |First nonempty |Use first nonempty |Firstdata}}&lt;br /&gt;
{{Lua|Module:If empty}}&lt;br /&gt;
{{High-use|all-pages = yes}}&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty|a|b|c}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#if:a|a|{{#if:b|b|c}}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, expression a and b do not have to be [[Don't repeat yourself|repeated]] and evaluated twice. The template provides a [[fallback]] order, similar to a [[try catch]] based &amp;quot;It is easier to ask for forgiveness than permission&amp;quot; ([[EAFP]]) programming style.&lt;br /&gt;
&lt;br /&gt;
Typical usage is like this:&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{If empty |{{{logo|}}} |{{{image|}}} |{{{picture|}}} |default.svg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: &amp;lt;nowiki&amp;gt;(&amp;quot;Return {{{logo|}}} if it has a value; else {{{image|}}} if it has a value; else {{{picture|}}} if it has a value; else return &amp;quot;default.svg&amp;quot;.&amp;quot;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
This returns the first of the parameters ''logo'', ''image'' and ''picture'' that is defined and non-empty, otherwise &amp;quot;default.svg&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Rationale===&lt;br /&gt;
The MediaWiki parameter default function doesn't return the default value for empty parameters. That is, &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{logo|default.svg}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; does not return &amp;quot;default.svg&amp;quot; if the template was called like this: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{template|logo=}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The usual workaround for a single parameter is:&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#if:{{{logo|}}} |{{{logo}}} |default.svg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: &amp;lt;nowiki&amp;gt;(&amp;quot;If {{{logo}}} has a value, return it, else return &amp;quot;default.svg&amp;quot;.&amp;quot;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But this becomes complex when several parameters are to be checked:&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#if:{{{logo|}}} |{{{logo}}} |{{#if:{{{image|}}} |{{{image}}} |{{#if:{{{picture|}}} |{{{picture}}} |default.svg}} }} }}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: &amp;lt;nowiki&amp;gt;(&amp;quot;If {{{logo}}} has a value, return it; else if {{{image}}} has a value, return that; else if {{{picture}}} has a value, return that; else return &amp;quot;default.svg&amp;quot;.&amp;quot;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
In these cases, {{tlf|if empty}} produces the simpler syntax (as above):&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty |{{{logo|}}} |{{{image|}}} |{{{picture|}}} |default.svg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Piping====&lt;br /&gt;
Parameters used with {{tlf|if empty}} must be [[Pipe (Unix)|pipe]]d&amp;amp;nbsp;– i.e. include the [[Vertical bar|vertical bar (pipe) symbol]] {{nowrap|(&amp;quot;{{thin space}}&amp;amp;#124;{{thin space}}&amp;quot;)}} as a trailing character&amp;amp;nbsp;– so that empty or undefined parameters aren't treated as text and returned incorrectly. Hence, for example, &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{logo|}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{image|}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{picture|}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; rather than {{param|logo}}, {{param|image}} and {{param|picture}} in the above examples.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
{{Aligned table |class=wikitable&lt;br /&gt;
 |cols=3 |col1style=padding-right:1.0em; |col2style=padding-left:0.5em;padding-right:1.0em; |col3style=padding-left:0.5em;&lt;br /&gt;
 |row1style=background:whitesmoke;padding-left:0.5em;font-weight:bold;&lt;br /&gt;
 | Code | Result |&lt;br /&gt;
 | {{tlc|if empty}} | {{if empty}} | Returns an empty string.&lt;br /&gt;
 | {{tlc|if empty|one}} | {{if empty|one}} | Returns the first parameter that is defined and not empty.&lt;br /&gt;
 | {{tlc|if empty|one|two}} | {{if empty|one|two}} | &lt;br /&gt;
 | {{tlc|if empty|one|two|three|four}} | {{if empty|one|two|three|four}} | &lt;br /&gt;
 | {{tlc|if empty||two}} | {{if empty||two}} | The first parameter is empty/undefined, so is passed over.&lt;br /&gt;
 | {{tlc|if empty||two|three|four}} | {{if empty||two|three|four}} | &lt;br /&gt;
 | {{tlc|if empty||two||four}} | {{if empty||two||four}} | &lt;br /&gt;
 | &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty||||||||||ten}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; | {{if empty||||||||||ten}} | Unlike in previous versions, this template is no longer limited by 9 parameters.&lt;br /&gt;
 | {{tlc|if empty{{!}}}} | {{if empty|}} | The only parameter is empty or undefined, so returns an empty string.&lt;br /&gt;
 | {{tlc|if empty|{{!}}{{!}}{{!}}{{!}}}} | {{if empty||||}} | Returns an empty string.&lt;br /&gt;
 | &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty|{{{1|}}}|{{{2|}}}|three}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; | {{if empty|{{{1|}}}|{{{2|}}}|three}} | &lt;br /&gt;
 | &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty|{{{1}}}|{{{2}}}|three}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; | {{if empty|{{{1}}}|{{{2}}}|three}} | No pipe-characters following the names of the first two parameters (&amp;quot;1&amp;quot; and &amp;quot;2&amp;quot;), so the first of these returned as text (&amp;quot;{{{1}}}&amp;quot;).&lt;br /&gt;
 | &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty|{{{logo|}}}|two}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; | {{if empty|{{{logo|}}}|two}} | &lt;br /&gt;
 | &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty|{{{logo}}}|two}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; | {{if empty|{{{logo}}}|two}} | No pipe-character following the parameter name &amp;quot;logo&amp;quot;, so the text &amp;quot;{{{logo}}}&amp;quot; returned.&lt;br /&gt;
 | &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty|p=q}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; | {{if empty|p=q}} | The template identifies the parameters it receives as parameters 1 to 9, not using names such as &amp;quot;p&amp;quot;, etc.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===See also===&lt;br /&gt;
* {{tl|if all}}&lt;br /&gt;
* {{tl|if either}}&lt;br /&gt;
* [[Help:Parameter default]]&lt;br /&gt;
* {{tl|Category see also if exists 2}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{Sandbox other|&lt;br /&gt;
| &amp;lt;!-- ADD TEMPLATE CATEGORIES BELOW THIS LINE, PLEASE: --&amp;gt;&lt;br /&gt;
[[Category:If-then-else templates]]&lt;br /&gt;
[[Category:Parameter selection templates]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kurt</name></author>
	</entry>
</feed>