<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://replication-ops.com/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://replication-ops.com/index.php?action=history&amp;feed=atom&amp;title=Template%3AIf_empty%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://replication-ops.com/index.php?title=Template:If_empty/doc&amp;action=history"/>
	<updated>2026-04-17T19:42:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://replication-ops.com/index.php?title=Template:If_empty/doc&amp;diff=6285&amp;oldid=prev</id>
		<title>Caseytube: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://replication-ops.com/index.php?title=Template:If_empty/doc&amp;diff=6285&amp;oldid=prev"/>
		<updated>2024-12-06T08:25:15Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&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 08:25, 6 December 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key repops_wiki:diff:1.41:old-6284:rev-6285 --&gt;
&lt;/table&gt;</summary>
		<author><name>Caseytube</name></author>
	</entry>
	<entry>
		<id>https://replication-ops.com/index.php?title=Template:If_empty/doc&amp;diff=6284&amp;oldid=prev</id>
		<title>Replication_Ops&gt;HTGS: Clean up examples: Some were not displaying pipes properly because of {{tlc}}, other examples were unnecessary, others needed some explanatory text</title>
		<link rel="alternate" type="text/html" href="https://replication-ops.com/index.php?title=Template:If_empty/doc&amp;diff=6284&amp;oldid=prev"/>
		<updated>2024-08-17T02:17:25Z</updated>

		<summary type="html">&lt;p&gt;Clean up examples: Some were not displaying pipes properly because of {{tlc}}, other examples were unnecessary, others needed some explanatory text&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;
{{Cascade-protected template}}&lt;br /&gt;
{{used in system}}&lt;br /&gt;
{{Lua|Module:If empty}}&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&amp;#039;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; ([[Time-of-check to time-of-use#Preventing TOCTOU|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;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;lt;/nowiki&amp;gt;&lt;br /&gt;
This returns the first of the parameters &amp;#039;&amp;#039;logo&amp;#039;&amp;#039;, &amp;#039;&amp;#039;image&amp;#039;&amp;#039; and &amp;#039;&amp;#039;picture&amp;#039;&amp;#039; 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&amp;#039;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;If {{{logo}}} has a value, return it, else return &amp;quot;default.svg&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;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;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&amp;#039;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|three|four}} | {{if empty|one|two|three|four}} | &lt;br /&gt;
 | &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty||two}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; | {{if empty||two}} | The first parameter is empty/undefined, so is passed over.&lt;br /&gt;
 | &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{if empty||two||four}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; | {{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 the template 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}} | Neither 1 nor 2 are defined, so &amp;quot;three&amp;quot; is returned.&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 is 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; is 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>Replication_Ops&gt;HTGS</name></author>
	</entry>
</feed>