Template:If
Jump to navigation
Jump to search
{{ safesubst:p{{ safesubst:#if{{{1}}}:{{{2}}}|1|2}}|{{{3}}}|}}
![]() |
This template is used on many pages, and changes to it will be widely noticed. Please test any changes in the template's /sandbox subpage, or in a user subpage, and consider discussing changes at the talk page before implementing them. |
With this template the parser functions 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.
This template can be substituted.
Usage
- {{if||x| p | q }} gives " p ". Notice the pair of vertical bars surrounding the empty first parameter.
- {{if|expr|2<3| p | q }} gives " p "
- {{if|eq| u |u| p | q }} gives " p "
- {{if|exist| Help:Link | p | q }} gives " q "
- {{if|error|{{#expr:x}}| p | q }} gives " p "
Compare:
- {{#if:x| p | q }} gives "p"
- {{#ifexpr:2<3| p | q }} gives "p"
- {{#ifeq: u |u| p | q }} gives "p"
- {{#ifexist: Help:Link | p | q }} gives "q"
- {{#iferror:{{#expr:x}}| p | q }} gives "p"
The above documentation is transcluded from Template:If/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories and interwikis to the /doc subpage. Subpages of this template. |