Template:If

From The Sonic Eats Rings Museum
Revision as of 23:03, 3 December 2008 by SoNick (talk | contribs) (New page: {{{{{subst|}}}p{{{{{subst|}}}#ifeq:{{{1}}}|eq|1|2}}|{{{{{subst|}}}p{{{{{subst|}}}#ifeq:{{{2}}}|{{{3}}}|1|2}}|{{{4|}}}|{{{5}}}}}|{{{{{subst|}}}p{{{{{subst|}}}#if{{{1}}}:{{{2}}}|1|2}}|{{{3}}...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

{{p{{#if{{{1}}}:{{{2}}}|1|2}}|{{{3}}}|}}

[edit] Template-info.svg Template documentation

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[edit]

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

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"

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]