Template:Ifwp

From Second Life Wiki
Revision as of 09:06, 16 September 2022 by Gwyneth Llewelyn (talk | contribs) (Shamelessly copied from meta.wikipedia.org)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
[Edit] [🔄Purge] Template documentation

This template allows branching without "Wikipedia logo"Extension:ParserFunctions.

It uses the code {{{3{{{1|}}}|{{{1{{{1|}}}|{{{2|}}}}}}}}}

Cases:

  • If __p1= is defined and not empty, this reduces to {{{2|}}}
  • If __p1= is defined and empty, this reduces to {{{3|}}}
  • If __p1= is undefined, this reduces to {{{3|{{{2|}}}}}}

If the intention is to treat empty and undefined as equivalent, then:

If __p1= is defined, we successfully avoid different results for __p2= undefined or empty, and for __p3= undefined or empty.

If __p1= is undefined and __p3= is defined, we successfully avoid different results for __p2= undefined or empty.

If __p1= and __p3= are undefined, we successfully avoid different results for __p2= undefined or empty.

If __p1= is undefined and __p2= is defined, we have __p2= for __p3= undefined, but empty for __p3= empty. This is different if __p2= is defined and not empty!

If __p1= and __p2= are undefined, we successfully avoid different results for __p3= undefined or empty.

If __p2= is defined and not empty and __p3= is undefined, we get __p2= if __p1= is undefined, but empty if __p1= is empty!

Summarizing: there is one deviating result: if __p2= is defined and not empty, we get this value if __p1= and __p3= are both undefined, but not if one of both are empty.

With ParserFunctions we can use {{#if:{{{1|}}}|{{{2|}}}|{{{3|}}}}}.

Examples

Code Result
{{ifwp|x|y|z}} y
{{ifwp||y|z}} z
{{ifwp|x||z}}
{{ifwp|x|y|}} y
{{ifwp|x||}}
{{ifwp||y|}}
{{ifwp|||z}} z
{{ifwp|||}}
{{ifwp|2=y|3=z}} z
{{ifwp|1=x|3=z}}
{{ifwp|x|y}} y
{{ifwp|2=|3=z}} z
{{ifwp|1=|3=z}} z
{{ifwp||y}}
{{ifwp|2=y|3=}}
{{ifwp|1=x|3=}}
{{ifwp|x|}}
{{ifwp|2=|3=}}
{{ifwp|1=|3=}}
{{ifwp||}}
{{ifwp|x}}
{{ifwp|2=y}} y
{{ifwp|3=z}} z
{{ifwp|}}
{{ifwp|2=}}
{{ifwp|3=}}
{{ifwp}}

See also