Template:If/doc: Difference between revisions

m 1 revision imported
No edit summary
 
Line 1: Line 1:
{{stack|{{Documentation subpage}}{{risky template}}{{cascade-protected template}}}}
{{stack|{{Documentation subpage}}}}
With this template the [[Help:parser function|parser functions]] of the [[mw:Help:Extension:ParserFunctions|ParserFunctions]] collection with names starting with "#if" can be used in a way such that they do not [[m:Manual:Newlines_and_spaces#Trimming_on_expansion|strip spaces and newlines]] from the "then" and "else" part. Spaces still do not affect the outcome of the condition. Parameter 1 selects the if-type as "eq", "expr", "exist" or "error" (for #iferror), or empty "||" 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.
<youtube>e2G8EWy-plM</youtube>
 
With this template the parser functions of the ParserFunctions collection with names starting with "#if" can be used in a way such that they do not strip spaces and newlines from the "then" and "else" part. Spaces still do not affect the outcome of the condition. Parameter 1 selects the if-type as "eq", "expr", "exist" or "error" (for #iferror), or empty "||" 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.


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 ("{{xtag|nowiki|s}}") could be used, without [[Template:If]], to allow a lead-space (such as "{{xtag|nowiki|s}}&nbsp;xx") anywhere, but the internal storage puts a 43-character marker for "{{xtag|nowiki|s}}" in string length. However, there is no extra expansion depth for a nowiki-tag, such as in trailing space, "zz&nbsp;{{xtag|nowiki|s}}".
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 ("{{xtag|nowiki|s}}") could be used, without [[Template:If]], to allow a lead-space (such as "{{xtag|nowiki|s}}&nbsp;xx") anywhere, but the internal storage puts a 43-character marker for "{{xtag|nowiki|s}}" in string length. However, there is no extra expansion depth for a nowiki-tag, such as in trailing space, "zz&nbsp;{{xtag|nowiki|s}}".