<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fa">
	<id>https://dezfulwiki.ir/index.php?action=history&amp;feed=atom&amp;title=%D8%A7%D9%84%DA%AF%D9%88%3AIf%2F%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA</id>
	<title>الگو:If/توضیحات - تاریخچهٔ نسخه‌ها</title>
	<link rel="self" type="application/atom+xml" href="https://dezfulwiki.ir/index.php?action=history&amp;feed=atom&amp;title=%D8%A7%D9%84%DA%AF%D9%88%3AIf%2F%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA"/>
	<link rel="alternate" type="text/html" href="https://dezfulwiki.ir/index.php?title=%D8%A7%D9%84%DA%AF%D9%88:If/%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA&amp;action=history"/>
	<updated>2026-04-07T06:24:46Z</updated>
	<subtitle>تاریخچهٔ نسخه‌ها برای این صفحه در ویکی</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>https://dezfulwiki.ir/index.php?title=%D8%A7%D9%84%DA%AF%D9%88:If/%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA&amp;diff=388&amp;oldid=prev</id>
		<title>Amin: ۱ نسخه واردشده</title>
		<link rel="alternate" type="text/html" href="https://dezfulwiki.ir/index.php?title=%D8%A7%D9%84%DA%AF%D9%88:If/%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA&amp;diff=388&amp;oldid=prev"/>
		<updated>2021-10-18T23:54:26Z</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;tr class=&quot;diff-title&quot; lang=&quot;fa&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;→ نسخهٔ قدیمی‌تر&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;نسخهٔ ‏۱۹ اکتبر ۲۰۲۱، ساعت ۰۹:۵۴&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;fa&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(بدون تفاوت)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Amin</name></author>
	</entry>
	<entry>
		<id>https://dezfulwiki.ir/index.php?title=%D8%A7%D9%84%DA%AF%D9%88:If/%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA&amp;diff=387&amp;oldid=prev</id>
		<title>dezfulwiki&gt;Modern Sciences: /* See also */</title>
		<link rel="alternate" type="text/html" href="https://dezfulwiki.ir/index.php?title=%D8%A7%D9%84%DA%AF%D9%88:If/%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA&amp;diff=387&amp;oldid=prev"/>
		<updated>2017-11-04T18:38:15Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;See also&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;صفحهٔ تازه&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Documentation subpage}}&amp;lt;includeonly&amp;gt;{{pp-template|small=yes}}&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
&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;exists&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;lt;nowiki&amp;gt;{{if||x| p | q }}&amp;lt;/nowiki&amp;gt; gives &amp;quot;{{if||x| p | q }}&amp;quot;. Notice the ''pair'' 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;
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:''' 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; ''extra'' &amp;quot;|&amp;quot; ''ends else-clause''&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; ''extra newline here''&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 [[اچ‌تی‌ام‌ال]]-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;
==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 41-level limit.&lt;br /&gt;
&lt;br /&gt;
'''Using P-if syntax:''' A similar if-structure can be coded without '''Template:If''', by using the {P1} and {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;nowiki&amp;gt;&amp;quot;{{P{{#ifexpr: 4 &amp;gt; 3|1|2}}| then 4 greater| else 4 lower}}&amp;quot;&amp;lt;/nowiki&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; ''the comparison invoked'' {&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;nowiki&amp;gt;&amp;quot;{{P{{#if:{{{2|x}}}|1|2}}| then {2} set| else {2} empty}}&amp;quot;&amp;lt;/nowiki&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; ''the comparison invoked'' {&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;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
[[رده:الگو:If-then-else]]&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>dezfulwiki&gt;Modern Sciences</name></author>
	</entry>
</feed>