(from m:) |
(→Internal technical details: rephrase) |
||
Line 11: | Line 11: | ||
==Internal technical details== | ==Internal technical details== | ||
For evaluating the condition the template uses | For evaluating the condition (determining non-emptiness of the first parameter) the template uses parser function #if, producing 1 if the condition is true, and 2 otherwise. The template with name equal to "P" followed by the index value produced (hence [[Template:P1]] or [[Template:P2]]), is called with as parameters p and q. This produces either p or q, without trimming. | ||
==See also== | ==See also== |
Revision as of 01:20, 31 December 2011
Documentation
With this template #if can be used in a way such that it does not strip spaces and newlines from the "then" and "else" part. For evaluating the condition spaces and newlines are stripped like with ParserFunctions.
Usage
{{ifnotempty|x| p | q }}
gives " p "{{ifnotempty|| p | q }}
gives " q "
Compare:
{{#if:x| p | q }}
gives "p"
Internal technical details
For evaluating the condition (determining non-emptiness of the first parameter) the template uses parser function #if, producing 1 if the condition is true, and 2 otherwise. The template with name equal to "P" followed by the index value produced (hence Template:P1 or Template:P2), is called with as parameters p and q. This produces either p or q, without trimming.
See also
[[[Category:If-then-else templates]]