Get our free book (in Spanish or English) on rainwater now - To Catch the Rain.

Difference between revisions of "Template:If/doc"

From Appropedia
Jump to: navigation, search
(started page)
Line 22: Line 22:
{{attrib wikipedia|Template:}}
[[Category:If-then-else templates]]
[[Category:If-then-else templates]]

Latest revision as of 04:51, 29 May 2011

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.


  • {{if||x| p | q }} gives " p "
  • {{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 "


  • {{#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"

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.

See also[edit]

This page or section includes content from Wikipedia. The original article was at Template:. The list of authors can be seen in the history for that page. As with Appropedia, the text of Wikipedia is available under the CC-BY-SA.