<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://compusofia.com/w/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://compusofia.com/w/index.php?action=history&amp;feed=atom&amp;title=Template%3AIf%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://compusofia.com/w/index.php?title=Template:If/doc&amp;action=history"/>
	<updated>2026-04-19T07:28:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://compusofia.com/w/index.php?title=Template:If/doc&amp;diff=2626&amp;oldid=prev</id>
		<title>Majestix: 1 revision imported: Initial Setup</title>
		<link rel="alternate" type="text/html" href="https://compusofia.com/w/index.php?title=Template:If/doc&amp;diff=2626&amp;oldid=prev"/>
		<updated>2026-04-12T06:54:54Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported: Initial Setup&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:54, 12 April 2026&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 wikiNonStop:diff:1.41:old-2625:rev-2626 --&gt;
&lt;/table&gt;</summary>
		<author><name>Majestix</name></author>
	</entry>
	<entry>
		<id>https://compusofia.com/w/index.php?title=Template:If/doc&amp;diff=2625&amp;oldid=prev</id>
		<title>en&gt;Chealer: Fix link</title>
		<link rel="alternate" type="text/html" href="https://compusofia.com/w/index.php?title=Template:If/doc&amp;diff=2625&amp;oldid=prev"/>
		<updated>2025-03-27T15:30:15Z</updated>

		<summary type="html">&lt;p&gt;Fix link&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;
[[Help:Extension:ParserFunctions|The functions provided by MediaWiki&amp;#039;s stock ParserFunctions extension]] with names starting with &amp;quot;#if&amp;quot; [[Manual:Newlines and spaces#Trimming on expansion|trim spaces and newlines]] from the &amp;quot;then&amp;quot; and &amp;quot;else&amp;quot; parts. &amp;#039;&amp;#039;&amp;#039;This mediawiki.org template is a wrapper&amp;#039;&amp;#039;&amp;#039; easing their use in a way that &amp;#039;&amp;#039;&amp;#039;prevents such trimming&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
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 that 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;nowiki&amp;gt;{{if||x| p | q }}&amp;lt;/nowiki&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;nowiki&amp;gt;{{if|expr|2&amp;lt;3| p | q }}&amp;lt;/nowiki&amp;gt; gives &amp;quot; p &amp;quot;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{if|eq| u |u| p | q }}&amp;lt;/nowiki&amp;gt; gives &amp;quot;{{if|eq| u |u| p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{if|exist| Help:Link | p | q }}&amp;lt;/nowiki&amp;gt; gives &amp;quot;{{if|exist| Help:Link | p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{if|error|{{#expr:x}}| p | q }}&amp;lt;/nowiki&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;nowiki&amp;gt;{{#if:x| p | q }}&amp;lt;/nowiki&amp;gt; gives &amp;quot;{{#if:x| p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{#ifexpr:2&amp;lt;3| p | q }}&amp;lt;/nowiki&amp;gt; gives &amp;quot;{{#ifexpr:2&amp;lt;3| p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{#ifeq: u |u| p | q }}&amp;lt;/nowiki&amp;gt; gives &amp;quot;{{#ifeq: u |u| p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{#ifexist: Help:Link | p | q }}&amp;lt;/nowiki&amp;gt; gives &amp;quot;{{#ifexist: Help:Link | p | q }}&amp;quot;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt;{{#iferror:{{#expr:x}}| p | q }}&amp;lt;/nowiki&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;nowiki&amp;gt;{{#ifeq: {{{parameter}}} |u| p | q }}&amp;lt;/nowiki&amp;gt;, entering the code &amp;lt;nowiki&amp;gt;{{{Template name|parameter=u}}}&amp;lt;/nowiki&amp;gt; into an article gives &amp;quot;p&amp;quot;, but &amp;lt;nowiki&amp;gt;{{{Template name|parameter=v}}}&amp;lt;/nowiki&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;quot; with &amp;quot;{{))}}&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Indentation:&amp;#039;&amp;#039;&amp;#039; 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;nowiki&amp;gt;{{if|{{{1|}}}&amp;lt;/nowiki&amp;gt;&amp;lt;br&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp; |then found parameter 1|else no parameter 1| &amp;amp;larr; &amp;#039;&amp;#039;extra&amp;#039;&amp;#039; &amp;quot;|&amp;quot; &amp;#039;&amp;#039;ends else-clause&amp;#039;&amp;#039;&amp;lt;br&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;nowiki&amp;gt;{{if|{{{1|}}}&amp;lt;/nowiki&amp;gt;&amp;lt;br&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp; |then found parameter 1 &amp;amp;larr; &amp;#039;&amp;#039;extra newline here&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp; |else noparameter 1|&amp;lt;br&amp;gt;}}&lt;br /&gt;
To indent the else-clause, split an [[HTML]]-form comment, as &amp;quot;&amp;amp;lt;!--&amp;quot; with next line as &amp;quot;--&amp;amp;gt;|else...&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;
==See also==&lt;br /&gt;
*[[m:Template:If]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
[[Category:Templates]]&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>en&gt;Chealer</name></author>
	</entry>
</feed>