<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pool.calebcooper.ie/index.php?action=history&amp;feed=atom&amp;title=Template%3AIf%2Fdoc</id>
	<title>Template:If/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pool.calebcooper.ie/index.php?action=history&amp;feed=atom&amp;title=Template%3AIf%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Template:If/doc&amp;action=history"/>
	<updated>2026-04-08T00:39:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://pool.calebcooper.ie/index.php?title=Template:If/doc&amp;diff=15209&amp;oldid=prev</id>
		<title>Caleb Cooper at 16:51, 2 November 2020</title>
		<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Template:If/doc&amp;diff=15209&amp;oldid=prev"/>
		<updated>2020-11-02T16:51:57Z</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 16:51, 2 November 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&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;{{stack|{{Documentation subpage}}{{high-risk}}}}{{Commons Import}}&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;{{stack|{{Documentation subpage}}{{high-risk}}}}{{Commons Import}}&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;With this template the [[Help:parser function|parser functions]] of the [[&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;mw&lt;/del&gt;:Help:Extension:ParserFunctions|ParserFunctions]] collection with names starting with &quot;#if&quot; can be used in a way such that they do not [[m:Help:Newlines_and_spaces#Stripping_on_expansion|strip spaces and newlines]] from the &quot;then&quot; and &quot;else&quot; part. Spaces still do not affect the outcome of the condition. Parameter 1 selects the if-type as &quot;eq&quot;, &quot;expr&quot;, &quot;exist&quot; or &quot;error&quot; (for #iferror), or empty &quot;||&quot; for a simple if-there (for #if). The template can be repeatedly nested 6 or 7 levels, one inside the other, because the outer-most is completed before running either the then/else inner levels.&lt;/div&gt;&lt;/td&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: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;With this template the [[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Wikipedia:&lt;/ins&gt;Help:parser function|parser functions]] of the [[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;mediawikiwiki&lt;/ins&gt;:Help:Extension:ParserFunctions|ParserFunctions]] collection with names starting with &quot;#if&quot; can be used in a way such that they do not [[m:Help:Newlines_and_spaces#Stripping_on_expansion|strip spaces and newlines]] from the &quot;then&quot; and &quot;else&quot; part. Spaces still do not affect the outcome of the condition. Parameter 1 selects the if-type as &quot;eq&quot;, &quot;expr&quot;, &quot;exist&quot; or &quot;error&quot; (for #iferror), or empty &quot;||&quot; for a simple if-there (for #if). The template can be repeatedly nested 6 or 7 levels, one inside the other, because the outer-most is completed before running either the then/else inner levels.&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;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 can be substituted, when the expression or comparison will not change. Functionally, a lead-space character is stored, internally, as a simple blank character. Note, in many cases a null nowiki tag (&quot;&amp;amp;lt;nowiki/&amp;gt;&quot;) could be used, without [[Template:If]], to allow a lead-space (such as &quot;&amp;amp;lt;nowiki/&amp;gt;&amp;amp;nbsp;xx&quot;) anywhere, but the internal storage puts a 43-character marker for &quot;&amp;amp;lt;nowiki/&amp;gt;&quot; in string length. However, there is no extra expansion depth for a nowiki-tag, such as in trailing space, &quot;zz&amp;amp;nbsp;&amp;amp;lt;nowiki/&amp;gt;&quot;.&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 can be substituted, when the expression or comparison will not change. Functionally, a lead-space character is stored, internally, as a simple blank character. Note, in many cases a null nowiki tag (&quot;&amp;amp;lt;nowiki/&amp;gt;&quot;) could be used, without [[Template:If]], to allow a lead-space (such as &quot;&amp;amp;lt;nowiki/&amp;gt;&amp;amp;nbsp;xx&quot;) anywhere, but the internal storage puts a 43-character marker for &quot;&amp;amp;lt;nowiki/&amp;gt;&quot; in string length. However, there is no extra expansion depth for a nowiki-tag, such as in trailing space, &quot;zz&amp;amp;nbsp;&amp;amp;lt;nowiki/&amp;gt;&quot;.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 35:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 35:&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;    |else noparameter 1|&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;    |else noparameter 1|&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;}}&amp;lt;/syntaxhighlight&amp;gt;&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;}}&amp;lt;/syntaxhighlight&amp;gt;&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;To indent the else-clause, split an [[HTML]]-form comment, as &quot;&amp;lt;code&amp;gt;&amp;amp;lt;!--&amp;lt;/code&amp;gt;&quot; with next line as &quot;&amp;lt;code&amp;gt;--&amp;amp;gt;|else...&amp;lt;/code&amp;gt;&quot;. Unless each then-clause and else-clause is carefully tested, to watch for extra newlines, then the results are likely to cause broken lines, with extra line breaks for each newline. For that reason, a global edit with simple search-and-replace of &quot;&amp;lt;code&amp;gt;{#if:&amp;lt;/code&amp;gt;&quot; to &quot;&amp;lt;code&amp;gt;{if||&amp;lt;/code&amp;gt;&quot; is likely to leave newline problems, wherever the original markup was wrapped to indent either the else-clause or &quot;}}&quot; of each if-structure. Indenting the then-clause is not a problem.&lt;/div&gt;&lt;/td&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: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To indent the else-clause, split an [[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Wikipedia:HTML|&lt;/ins&gt;HTML]]-form comment, as &quot;&amp;lt;code&amp;gt;&amp;amp;lt;!--&amp;lt;/code&amp;gt;&quot; with next line as &quot;&amp;lt;code&amp;gt;--&amp;amp;gt;|else...&amp;lt;/code&amp;gt;&quot;. Unless each then-clause and else-clause is carefully tested, to watch for extra newlines, then the results are likely to cause broken lines, with extra line breaks for each newline. For that reason, a global edit with simple search-and-replace of &quot;&amp;lt;code&amp;gt;{#if:&amp;lt;/code&amp;gt;&quot; to &quot;&amp;lt;code&amp;gt;{if||&amp;lt;/code&amp;gt;&quot; is likely to leave newline problems, wherever the original markup was wrapped to indent either the else-clause or &quot;}}&quot; of each if-structure. Indenting the then-clause is not a problem.&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;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;==Performance considerations==&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;==Performance considerations==&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;Because [[Template:If]] must prepare the parameters for &amp;lt;code&amp;gt;#if, #ifeq, #ifexpr,&amp;lt;/code&amp;gt; (etc.) there is a slight overhead when using it. It has been timed to run at speeds of 290 instances per second, so 29 uses would take only 0.1&amp;amp;nbsp;s, a tenth of a second to run, to make 29 comparisons. Each nested use adds 5 levels to the template expansion depth, so 7 nested if-templates would use 35 levels (5*7) of the [[&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;m&lt;/del&gt;:Help:Expansion_depth|41-level limit]].&lt;/div&gt;&lt;/td&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: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Because [[Template:If]] must prepare the parameters for &amp;lt;code&amp;gt;#if, #ifeq, #ifexpr,&amp;lt;/code&amp;gt; (etc.) there is a slight overhead when using it. It has been timed to run at speeds of 290 instances per second, so 29 uses would take only 0.1&amp;amp;nbsp;s, a tenth of a second to run, to make 29 comparisons. Each nested use adds 5 levels to the template expansion depth, so 7 nested if-templates would use 35 levels (5*7) of the [[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;mediawikiwiki&lt;/ins&gt;:Help:Expansion_depth|41-level limit]].&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;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;&#039;&#039;&#039;Using P-if syntax:&#039;&#039;&#039; A similar if-structure can be coded without &#039;&#039;&#039;Template:If&#039;&#039;&#039;, by using the {{tlx|P1}} and {{tlx|P2}} templates in a &quot;P-if&quot; structure. [[Template:P1]] always returns parameter 1, and P2 returns the 2nd. So, a comparison of 4 versus 3 can be coded using P-if syntax form:&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;&#039;&#039;&#039;Using P-if syntax:&#039;&#039;&#039; A similar if-structure can be coded without &#039;&#039;&#039;Template:If&#039;&#039;&#039;, by using the {{tlx|P1}} and {{tlx|P2}} templates in a &quot;P-if&quot; structure. [[Template:P1]] always returns parameter 1, and P2 returns the 2nd. So, a comparison of 4 versus 3 can be coded using P-if syntax form:&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 49:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 49:&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;==See also==&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;==See also==&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;*[[m:Template:If]]&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty 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;div&gt;*[[Template:Ifnotempty]] - for simplicity and to reduce the limitations due to the expansion depth limit, this is a separate template corresponding to #if only.&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:Ifnotempty]] - for simplicity and to reduce the limitations due to the expansion depth limit, this is a separate template corresponding to #if only.&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;*[[Template:Switch]], for a default result&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:Switch]], for a default result&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;*[[Help:Conditional expressions]]&lt;/div&gt;&lt;/td&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: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*[[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Wikipedia:Help:Conditional expressions|&lt;/ins&gt;Help:Conditional expressions]]&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;&amp;lt;includeonly&amp;gt;{{Sandbox other||&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;&amp;lt;includeonly&amp;gt;{{Sandbox other||&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;[[Category:If-then-else templates]]&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;[[Category:If-then-else templates]]&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Caleb Cooper</name></author>
	</entry>
	<entry>
		<id>https://pool.calebcooper.ie/index.php?title=Template:If/doc&amp;diff=15197&amp;oldid=prev</id>
		<title>Caleb Cooper: Created page with &quot;{{stack|{{Documentation subpage}}{{high-risk}}}}{{Commons Import}} With this template the parser functions of the mw:Help:Extension:ParserFunctions|...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Template:If/doc&amp;diff=15197&amp;oldid=prev"/>
		<updated>2020-11-02T16:43:30Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{stack|{{Documentation subpage}}{{high-risk}}}}{{Commons Import}} With this template the &lt;a href=&quot;/index.php?title=Help:Parser_function&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Help:Parser function (page does not exist)&quot;&gt;parser functions&lt;/a&gt; of the mw:Help:Extension:ParserFunctions|...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{stack|{{Documentation subpage}}{{high-risk}}}}{{Commons Import}}&lt;br /&gt;
With this template the [[Help:parser function|parser functions]] of the [[mw:Help:Extension:ParserFunctions|ParserFunctions]] collection with names starting with &amp;quot;#if&amp;quot; can be used in a way such that they do not [[m:Help:Newlines_and_spaces#Stripping_on_expansion|strip spaces and newlines]] from the &amp;quot;then&amp;quot; and &amp;quot;else&amp;quot; part. Spaces still do not affect the outcome of the condition. Parameter 1 selects the if-type as &amp;quot;eq&amp;quot;, &amp;quot;expr&amp;quot;, &amp;quot;exist&amp;quot; or &amp;quot;error&amp;quot; (for #iferror), or empty &amp;quot;||&amp;quot; for a simple if-there (for #if). The template can be repeatedly nested 6 or 7 levels, one inside the other, because the outer-most is completed before running either the then/else inner levels.&lt;br /&gt;
&lt;br /&gt;
This template can be substituted, when the expression or comparison will not change. Functionally, a lead-space character is stored, internally, as a simple blank character. Note, in many cases a null nowiki tag (&amp;quot;&amp;amp;lt;nowiki/&amp;gt;&amp;quot;) could be used, without [[Template:If]], to allow a lead-space (such as &amp;quot;&amp;amp;lt;nowiki/&amp;gt;&amp;amp;nbsp;xx&amp;quot;) anywhere, but the internal storage puts a 43-character marker for &amp;quot;&amp;amp;lt;nowiki/&amp;gt;&amp;quot; in string length. However, there is no extra expansion depth for a nowiki-tag, such as in trailing space, &amp;quot;zz&amp;amp;nbsp;&amp;amp;lt;nowiki/&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Where p is implemented in affirmation of the statement and q is implemented in negation of the statement&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{if||x| p | q }}&amp;lt;/syntaxhighlight&amp;gt; gives &amp;quot;{{if||x| p | q }}&amp;quot;. Notice the &amp;#039;&amp;#039;pair&amp;#039;&amp;#039; of vertical bars surrounding the empty first parameter.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{if|expr|2&amp;lt;3| p | q }}&amp;lt;/syntaxhighlight&amp;gt; gives &amp;quot; p &amp;quot;&lt;br /&gt;
*&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{if|eq| u |u| p | q }}&amp;lt;/syntaxhighlight&amp;gt; gives &amp;quot;{{if|eq| u |u| p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{if|exist| Help:Link | p | q }}&amp;lt;/syntaxhighlight&amp;gt; gives &amp;quot;{{if|exist| Help:Link | p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{if|error|{{#expr:x}}| p | q }}&amp;lt;/syntaxhighlight&amp;gt; gives &amp;quot;{{if|error|{{#expr:x}}| p | q }}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Compare:&lt;br /&gt;
*&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{#if:x| p | q }}&amp;lt;/syntaxhighlight&amp;gt; gives &amp;quot;{{#if:x| p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{#ifexpr:2&amp;lt;3| p | q }}&amp;lt;/syntaxhighlight&amp;gt; gives &amp;quot;{{#ifexpr:2&amp;lt;3| p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{#ifeq: u |u| p | q }}&amp;lt;/syntaxhighlight&amp;gt; gives &amp;quot;{{#ifeq: u |u| p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{#ifexist: Help:Link | p | q }}&amp;lt;/syntaxhighlight&amp;gt; gives &amp;quot;{{#ifexist: Help:Link | p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{#iferror:{{#expr:x}}| p | q }}&amp;lt;/syntaxhighlight&amp;gt; gives &amp;quot;{{#iferror:{{#expr:x}}| p | q }}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For example, with a template named &amp;#039;&amp;#039;Template:Template name&amp;#039;&amp;#039; containing the code &amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{#ifeq: {{{parameter}}} |u| p | q }}&amp;lt;/syntaxhighlight&amp;gt;, entering the code &amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{{Template name|parameter=u}}}&amp;lt;/syntaxhighlight&amp;gt; into an article gives &amp;quot;p&amp;quot;, but &amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;{{{Template name|parameter=v}}}&amp;lt;/syntaxhighlight&amp;gt; gives &amp;quot;q&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The text of either the then-clause or else-clause is only processed and expanded when triggered. Hence, any templates in use are only expanded once the then-clause or else-clause is matched, otherwise they are skipped as merely paired braces, &amp;quot;&amp;amp;#123;&amp;amp;#123;&amp;quot; with &amp;quot;}}&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Indentation===&lt;br /&gt;
If indenting the markup, care must be taken to avoid extra newlines when indenting &amp;quot;}}&amp;quot; on the next line. An extra bar pipe &amp;quot;|&amp;quot; can be added after the else-clause to complete that text, and allow &amp;quot;}}&amp;quot; to then be placed anywhere without adding a newline into the else-clause. For example:&lt;br /&gt;
:::* &amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;{{if|{{{1|}}}&lt;br /&gt;
    |then found parameter 1|else no parameter 1| ← extra &amp;quot;|&amp;quot; ends else-clause&lt;br /&gt;
}}&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
When the else-clause is indented to the next line, a newline (CR/LF) is added:&lt;br /&gt;
:::* &amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;{{if|{{{1|}}}&lt;br /&gt;
    |then found parameter 1 ← extra newline here&lt;br /&gt;
    |else noparameter 1|&lt;br /&gt;
}}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To indent the else-clause, split an [[HTML]]-form comment, as &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;!--&amp;lt;/code&amp;gt;&amp;quot; with next line as &amp;quot;&amp;lt;code&amp;gt;--&amp;amp;gt;|else...&amp;lt;/code&amp;gt;&amp;quot;. Unless each then-clause and else-clause is carefully tested, to watch for extra newlines, then the results are likely to cause broken lines, with extra line breaks for each newline. For that reason, a global edit with simple search-and-replace of &amp;quot;&amp;lt;code&amp;gt;{#if:&amp;lt;/code&amp;gt;&amp;quot; to &amp;quot;&amp;lt;code&amp;gt;{if||&amp;lt;/code&amp;gt;&amp;quot; is likely to leave newline problems, wherever the original markup was wrapped to indent either the else-clause or &amp;quot;}}&amp;quot; of each if-structure. Indenting the then-clause is not a problem.&lt;br /&gt;
&lt;br /&gt;
==Performance considerations==&lt;br /&gt;
Because [[Template:If]] must prepare the parameters for &amp;lt;code&amp;gt;#if, #ifeq, #ifexpr,&amp;lt;/code&amp;gt; (etc.) there is a slight overhead when using it. It has been timed to run at speeds of 290 instances per second, so 29 uses would take only 0.1&amp;amp;nbsp;s, a tenth of a second to run, to make 29 comparisons. Each nested use adds 5 levels to the template expansion depth, so 7 nested if-templates would use 35 levels (5*7) of the [[m:Help:Expansion_depth|41-level limit]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using P-if syntax:&amp;#039;&amp;#039;&amp;#039; A similar if-structure can be coded without &amp;#039;&amp;#039;&amp;#039;Template:If&amp;#039;&amp;#039;&amp;#039;, by using the {{tlx|P1}} and {{tlx|P2}} templates in a &amp;quot;P-if&amp;quot; structure. [[Template:P1]] always returns parameter 1, and P2 returns the 2nd. So, a comparison of 4 versus 3 can be coded using P-if syntax form:&lt;br /&gt;
:: Example of &amp;lt;code&amp;gt;#ifexpr&amp;lt;/code&amp;gt;: &amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;&amp;quot;{{P{{#ifexpr: 4 &amp;gt; 3|1|2}}| then 4 greater| else 4 lower}}&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
:: Result for &amp;lt;code&amp;gt;#ifexpr&amp;lt;/code&amp;gt;: &amp;amp;nbsp; &amp;quot;{{P{{#ifexpr: 4 &amp;gt; 3|1|2}}| then 4 greater| else 4 lower}}&amp;quot; &amp;amp;larr; &amp;#039;&amp;#039;the comparison invoked&amp;#039;&amp;#039; {&amp;lt;nowiki/&amp;gt;{P1}}.&lt;br /&gt;
The expansion depth of a P-if is only 4 levels deep, but nesting of the then-clause or else-clause might be more confusing than using nested levels of Template:if.&lt;br /&gt;
&lt;br /&gt;
:: Example of &amp;lt;code&amp;gt;#if&amp;lt;/code&amp;gt;: &amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; inline&amp;gt;&amp;quot;{{P{{#if:{{{2|x}}}|1|2}}| then {2} set| else {2} empty}}&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
:: Result for &amp;lt;code&amp;gt;#if&amp;lt;/code&amp;gt;: &amp;quot;{{P{{#if:{{{2|}}}|1|2}}| then {2} set| else {2} empty}}&amp;quot; &amp;amp;larr; &amp;#039;&amp;#039;the comparison invoked&amp;#039;&amp;#039; {&amp;lt;nowiki/&amp;gt;{P2}}.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[m:Template:If]]&lt;br /&gt;
*[[Template:Ifnotempty]] - for simplicity and to reduce the limitations due to the expansion depth limit, this is a separate template corresponding to #if only.&lt;br /&gt;
*[[Template:Switch]], for a default result&lt;br /&gt;
*[[Help:Conditional expressions]]&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{Sandbox other||&lt;br /&gt;
[[Category:If-then-else templates]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caleb Cooper</name></author>
	</entry>
</feed>