Template:Ifexpr
With this template #ifexpr can be used in a way such that it does not strip spaces and newlines from the "then" and "else" part.
Usage
{{ifexpr|2<3| p | q }}
gives "With this template #ifexpr can be used in a way such that it does not strip spaces and newlines from the "then" and "else" part.
Usage
{{ifexpr|2<3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2>3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2{{=}}3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|7{{=}}7| ok true | no }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|3*4<{{=}}10+1| ok| oh no}}
gives "Template loop detected: Template:Ifexpr"
Compare:
{{#ifexpr:2<3| p | q }}
gives "p"
Note that, unlike parser functions, templates require writing equals signs in values of unnamed parameters by using double-braces, as {{=}}
. So, to allow "=" (or "<=" or ">=") then use the named parameter 1, as in: 1={{{x}}}>=7.
For full substitution, simply use subst:
or safesubst:
. If the condition contains a parser function, template, or variable, that should be substituted too. Optionally the "then" or "else" part can also be substituted.
Error messages (examples):
{{ifexpr|1234>e3|1|0}}
gives Template loop detected: Template:Ifexpr{{#ifexpr:1234>e3|1|0}}
gives Expression error: Unexpected number., for e3.{{#ifexpr:1234>1e3|1|0}}
gives 1, because 1,234 > 1e3 (1,000).
Expansion depth limit
During 2011-2012, the nesting limit of {Ifexpr} was 12 nested structures (this is one of the template limits for the MediaWiki parser). For example, nesting 13 times can cause an error:
{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|a}}}}}}}}}}}}}}}}}}}}}}}}}}
- Result: {{safesubst:{{Expansion depth limit exceeded|p1=p1|p2=p2|if/errmsg}}|a||1}}
The expansion-depth error occurs when exceeding the depth limit of nested markup, typically 41 levels of nested templates or if-else structures, during 2009-2012.
Internal technical details
For evaluating the condition the template uses the actual parser functions; however, not directly with p and q, because this strips spaces and newlines from them, but with index values 1 and 2. The result can be 1, 2, or an error message. Using a switch these are converted to p1, p2, and if/errmsg, respectively. The template with the applicable name is called (Template:P1, Template:P2, or Template:If/errmsg), with as parameters p, q, and 2<3. Templates p1 and p2 ignore 2<3; template if/errmsg is only called in the case of a wrong expression 2<3; it ignores p and q and uses 2<3 for display in the error message.
Dependencies
This template depends on the existence of
See also
"
{{ifexpr|2>3| p | q }}
gives "With this template #ifexpr can be used in a way such that it does not strip spaces and newlines from the "then" and "else" part.
Usage
{{ifexpr|2<3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2>3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2{{=}}3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|7{{=}}7| ok true | no }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|3*4<{{=}}10+1| ok| oh no}}
gives "Template loop detected: Template:Ifexpr"
Compare:
{{#ifexpr:2<3| p | q }}
gives "p"
Note that, unlike parser functions, templates require writing equals signs in values of unnamed parameters by using double-braces, as {{=}}
. So, to allow "=" (or "<=" or ">=") then use the named parameter 1, as in: 1={{{x}}}>=7.
For full substitution, simply use subst:
or safesubst:
. If the condition contains a parser function, template, or variable, that should be substituted too. Optionally the "then" or "else" part can also be substituted.
Error messages (examples):
{{ifexpr|1234>e3|1|0}}
gives Template loop detected: Template:Ifexpr{{#ifexpr:1234>e3|1|0}}
gives Expression error: Unexpected number., for e3.{{#ifexpr:1234>1e3|1|0}}
gives 1, because 1,234 > 1e3 (1,000).
Expansion depth limit
During 2011-2012, the nesting limit of {Ifexpr} was 12 nested structures (this is one of the template limits for the MediaWiki parser). For example, nesting 13 times can cause an error:
{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|a}}}}}}}}}}}}}}}}}}}}}}}}}}
- Result: {{safesubst:{{Expansion depth limit exceeded|p1=p1|p2=p2|if/errmsg}}|a||1}}
The expansion-depth error occurs when exceeding the depth limit of nested markup, typically 41 levels of nested templates or if-else structures, during 2009-2012.
Internal technical details
For evaluating the condition the template uses the actual parser functions; however, not directly with p and q, because this strips spaces and newlines from them, but with index values 1 and 2. The result can be 1, 2, or an error message. Using a switch these are converted to p1, p2, and if/errmsg, respectively. The template with the applicable name is called (Template:P1, Template:P2, or Template:If/errmsg), with as parameters p, q, and 2>3. Templates p1 and p2 ignore 2>3; template if/errmsg is only called in the case of a wrong expression 2>3; it ignores p and q and uses 2>3 for display in the error message.
Dependencies
This template depends on the existence of
See also
"
{{ifexpr|2{{=}}3| p | q }}
gives "With this template #ifexpr can be used in a way such that it does not strip spaces and newlines from the "then" and "else" part.
Usage
{{ifexpr|2<3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2>3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2{{=}}3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|7{{=}}7| ok true | no }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|3*4<{{=}}10+1| ok| oh no}}
gives "Template loop detected: Template:Ifexpr"
Compare:
{{#ifexpr:2<3| p | q }}
gives "p"
Note that, unlike parser functions, templates require writing equals signs in values of unnamed parameters by using double-braces, as {{=}}
. So, to allow "=" (or "<=" or ">=") then use the named parameter 1, as in: 1={{{x}}}>=7.
For full substitution, simply use subst:
or safesubst:
. If the condition contains a parser function, template, or variable, that should be substituted too. Optionally the "then" or "else" part can also be substituted.
Error messages (examples):
{{ifexpr|1234>e3|1|0}}
gives Template loop detected: Template:Ifexpr{{#ifexpr:1234>e3|1|0}}
gives Expression error: Unexpected number., for e3.{{#ifexpr:1234>1e3|1|0}}
gives 1, because 1,234 > 1e3 (1,000).
Expansion depth limit
During 2011-2012, the nesting limit of {Ifexpr} was 12 nested structures (this is one of the template limits for the MediaWiki parser). For example, nesting 13 times can cause an error:
{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|a}}}}}}}}}}}}}}}}}}}}}}}}}}
- Result: {{safesubst:{{Expansion depth limit exceeded|p1=p1|p2=p2|if/errmsg}}|a||1}}
The expansion-depth error occurs when exceeding the depth limit of nested markup, typically 41 levels of nested templates or if-else structures, during 2009-2012.
Internal technical details
For evaluating the condition the template uses the actual parser functions; however, not directly with p and q, because this strips spaces and newlines from them, but with index values 1 and 2. The result can be 1, 2, or an error message. Using a switch these are converted to p1, p2, and if/errmsg, respectively. The template with the applicable name is called (Template:P1, Template:P2, or Template:If/errmsg), with as parameters p, q, and 2=3. Templates p1 and p2 ignore 2=3; template if/errmsg is only called in the case of a wrong expression 2=3; it ignores p and q and uses 2=3 for display in the error message.
Dependencies
This template depends on the existence of
See also
"
{{ifexpr|7{{=}}7| ok true | no }}
gives "With this template #ifexpr can be used in a way such that it does not strip spaces and newlines from the "then" and "else" part.
Usage
{{ifexpr|2<3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2>3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2{{=}}3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|7{{=}}7| ok true | no }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|3*4<{{=}}10+1| ok| oh no}}
gives "Template loop detected: Template:Ifexpr"
Compare:
{{#ifexpr:2<3| p | q }}
gives "p"
Note that, unlike parser functions, templates require writing equals signs in values of unnamed parameters by using double-braces, as {{=}}
. So, to allow "=" (or "<=" or ">=") then use the named parameter 1, as in: 1={{{x}}}>=7.
For full substitution, simply use subst:
or safesubst:
. If the condition contains a parser function, template, or variable, that should be substituted too. Optionally the "then" or "else" part can also be substituted.
Error messages (examples):
{{ifexpr|1234>e3|1|0}}
gives Template loop detected: Template:Ifexpr{{#ifexpr:1234>e3|1|0}}
gives Expression error: Unexpected number., for e3.{{#ifexpr:1234>1e3|1|0}}
gives 1, because 1,234 > 1e3 (1,000).
Expansion depth limit
During 2011-2012, the nesting limit of {Ifexpr} was 12 nested structures (this is one of the template limits for the MediaWiki parser). For example, nesting 13 times can cause an error:
{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|a}}}}}}}}}}}}}}}}}}}}}}}}}}
- Result: {{safesubst:{{Expansion depth limit exceeded|p1=p1|p2=p2|if/errmsg}}|a||1}}
The expansion-depth error occurs when exceeding the depth limit of nested markup, typically 41 levels of nested templates or if-else structures, during 2009-2012.
Internal technical details
For evaluating the condition the template uses the actual parser functions; however, not directly with p and q, because this strips spaces and newlines from them, but with index values 1 and 2. The result can be 1, 2, or an error message. Using a switch these are converted to p1, p2, and if/errmsg, respectively. The template with the applicable name is called (Template:P1, Template:P2, or Template:If/errmsg), with as parameters p, q, and 7=7. Templates p1 and p2 ignore 7=7; template if/errmsg is only called in the case of a wrong expression 7=7; it ignores p and q and uses 7=7 for display in the error message.
Dependencies
This template depends on the existence of
See also
"
{{ifexpr|3*4<{{=}}10+1| ok| oh no}}
gives "With this template #ifexpr can be used in a way such that it does not strip spaces and newlines from the "then" and "else" part.
Usage
{{ifexpr|2<3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2>3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2{{=}}3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|7{{=}}7| ok true | no }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|3*4<{{=}}10+1| ok| oh no}}
gives "Template loop detected: Template:Ifexpr"
Compare:
{{#ifexpr:2<3| p | q }}
gives "p"
Note that, unlike parser functions, templates require writing equals signs in values of unnamed parameters by using double-braces, as {{=}}
. So, to allow "=" (or "<=" or ">=") then use the named parameter 1, as in: 1={{{x}}}>=7.
For full substitution, simply use subst:
or safesubst:
. If the condition contains a parser function, template, or variable, that should be substituted too. Optionally the "then" or "else" part can also be substituted.
Error messages (examples):
{{ifexpr|1234>e3|1|0}}
gives Template loop detected: Template:Ifexpr{{#ifexpr:1234>e3|1|0}}
gives Expression error: Unexpected number., for e3.{{#ifexpr:1234>1e3|1|0}}
gives 1, because 1,234 > 1e3 (1,000).
Expansion depth limit
During 2011-2012, the nesting limit of {Ifexpr} was 12 nested structures (this is one of the template limits for the MediaWiki parser). For example, nesting 13 times can cause an error:
{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|a}}}}}}}}}}}}}}}}}}}}}}}}}}
- Result: {{safesubst:{{Expansion depth limit exceeded|p1=p1|p2=p2|if/errmsg}}|a||1}}
The expansion-depth error occurs when exceeding the depth limit of nested markup, typically 41 levels of nested templates or if-else structures, during 2009-2012.
Internal technical details
For evaluating the condition the template uses the actual parser functions; however, not directly with p and q, because this strips spaces and newlines from them, but with index values 1 and 2. The result can be 1, 2, or an error message. Using a switch these are converted to p1, p2, and if/errmsg, respectively. The template with the applicable name is called (Template:P1, Template:P2, or Template:If/errmsg), with as parameters p, q, and 3*4<=10+1. Templates p1 and p2 ignore 3*4<=10+1; template if/errmsg is only called in the case of a wrong expression 3*4<=10+1; it ignores p and q and uses 3*4<=10+1 for display in the error message.
Dependencies
This template depends on the existence of
See also
"
Compare:
{{#ifexpr:2<3| p | q }}
gives "p"
Note that, unlike parser functions, templates require writing equals signs in values of unnamed parameters by using double-braces, as {{=}}
. So, to allow "=" (or "<=" or ">=") then use the named parameter 1, as in: 1={{{x}}}>=7.
For full substitution, simply use subst:
or safesubst:
. If the condition contains a parser function, template, or variable, that should be substituted too. Optionally the "then" or "else" part can also be substituted.
Error messages (examples):
{{ifexpr|1234>e3|1|0}}
gives With this template #ifexpr can be used in a way such that it does not strip spaces and newlines from the "then" and "else" part.
Usage
{{ifexpr|2<3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2>3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|2{{=}}3| p | q }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|7{{=}}7| ok true | no }}
gives "Template loop detected: Template:Ifexpr"{{ifexpr|3*4<{{=}}10+1| ok| oh no}}
gives "Template loop detected: Template:Ifexpr"
Compare:
{{#ifexpr:2<3| p | q }}
gives "p"
Note that, unlike parser functions, templates require writing equals signs in values of unnamed parameters by using double-braces, as {{=}}
. So, to allow "=" (or "<=" or ">=") then use the named parameter 1, as in: 1={{{x}}}>=7.
For full substitution, simply use subst:
or safesubst:
. If the condition contains a parser function, template, or variable, that should be substituted too. Optionally the "then" or "else" part can also be substituted.
Error messages (examples):
{{ifexpr|1234>e3|1|0}}
gives Template loop detected: Template:Ifexpr{{#ifexpr:1234>e3|1|0}}
gives Expression error: Unexpected number., for e3.{{#ifexpr:1234>1e3|1|0}}
gives 1, because 1,234 > 1e3 (1,000).
Expansion depth limit
During 2011-2012, the nesting limit of {Ifexpr} was 12 nested structures (this is one of the template limits for the MediaWiki parser). For example, nesting 13 times can cause an error:
{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|a}}}}}}}}}}}}}}}}}}}}}}}}}}
- Result: {{safesubst:{{Expansion depth limit exceeded|p1=p1|p2=p2|if/errmsg}}|a||1}}
The expansion-depth error occurs when exceeding the depth limit of nested markup, typically 41 levels of nested templates or if-else structures, during 2009-2012.
Internal technical details
For evaluating the condition the template uses the actual parser functions; however, not directly with p and q, because this strips spaces and newlines from them, but with index values 1 and 2. The result can be 1, 2, or an error message. Using a switch these are converted to p1, p2, and if/errmsg, respectively. The template with the applicable name is called (Template:P1, Template:P2, or Template:If/errmsg), with as parameters p, q, and 1234>e3. Templates p1 and p2 ignore 1234>e3; template if/errmsg is only called in the case of a wrong expression 1234>e3; it ignores p and q and uses 1234>e3 for display in the error message.
Dependencies
This template depends on the existence of
See also
{{#ifexpr:1234>e3|1|0}}
gives Expression error: Unexpected number., for e3.{{#ifexpr:1234>1e3|1|0}}
gives 1, because 1,234 > 1e3 (1,000).
Expansion depth limit
During 2011-2012, the nesting limit of {Ifexpr} was 12 nested structures (this is one of the template limits for the MediaWiki parser). For example, nesting 13 times can cause an error:
{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|{{ifexpr|1|a}}}}}}}}}}}}}}}}}}}}}}}}}}
- Result: {{safesubst:{{Expansion depth limit exceeded|p1=p1|p2=p2|if/errmsg}}|a||1}}
The expansion-depth error occurs when exceeding the depth limit of nested markup, typically 41 levels of nested templates or if-else structures, during 2009-2012.
Internal technical details
For evaluating the condition the template uses the actual parser functions; however, not directly with p and q, because this strips spaces and newlines from them, but with index values 1 and 2. The result can be 1, 2, or an error message. Using a switch these are converted to p1, p2, and if/errmsg, respectively. The template with the applicable name is called (Template:P1, Template:P2, or Template:If/errmsg), with as parameters p, q, and {{{1}}}. Templates p1 and p2 ignore {{{1}}}; template if/errmsg is only called in the case of a wrong expression {{{1}}}; it ignores p and q and uses {{{1}}} for display in the error message.
Dependencies
This template depends on the existence of
See also