User:DESiegel60/If-PF/Doc
< User:DESiegel60 | If-PF
Jump to navigation
Jump to search
Revision as of 15:43, 13 May 2008 by DESiegel60 (talk | contribs) (Template:If/Doc moved to User:DESiegel60/If-PF/Doc)
Purpose
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.
Usage
- {{if||x| p | q }} gives "Template:If"
- {{if|expr|2<3| p | q }} gives " p "
- {{if|eq| u |u| p | q }} gives "Template:If"
- {{if|exist| Help:Link | p | q }} gives "Template:If"
- {{if|error|{{#expr:x}}| p | q }} gives "Template:If"
Compare:
- {{#if:x| p | q }} gives "{{#if:x| p | q }}"
- {{#ifexpr:2<3| p | q }} gives "{{#ifexpr:2<3| p | q }}"
- {{#ifeq: u |u| p | q }} gives "{{#ifeq: u |u| p | q }}"
- {{#ifexist: Help:Link | p | q }} gives "{{#ifexist: Help:Link | p | q }}"
- {{#iferror:{{#expr:x}}| p | q }} gives "{{#iferror:{{#expr:x}}| p | q }}"
For full substitution, use e.g. {{subst:if|expr|2<3| p | q |subst=subst:}}. If the condition contains a parser function or template etc., that should be substituted too. Optionally the "then" or "else" part can also be substituted.