Template:Ifwp/docEdit This Page
From FamilySearch Wiki
|
|
This is a documentation subpage for Template:Ifwp (see that page for the template itself). It contains usage information, categories and other content that is not part of the original template page. |
This template allows branching without mw:Extension:ParserFunctions.
It uses the code {{{3{{{1|}}}|{{{1{{{1|}}}|{{{2|}}}}}}}}}
Cases:
- If {{{1}}} is defined and not empty, this reduces to
{{{2|}}} - If {{{1}}} is defined and empty, this reduces to
{{{3|}}} - If {{{1}}} is undefined, this reduces to
{{{3|{{{2|}}}}}}
If the intention is to treat empty and undefined as equivalent, then:
If {{{1}}} is defined, we successfully avoid different results for {{{2}}} undefined or empty, and for {{{3}}} undefined or empty.
If {{{1}}} is undefined and {{{3}}} is defined, we successfully avoid different results for {{{2}}} undefined or empty.
If {{{1}}} and {{{3}}} are undefined, we successfully avoid different results for {{{2}}} undefined or empty.
If {{{1}}} is undefined and {{{2}}} is defined, we have {{{2}}} for {{{3}}} undefined, but empty for {{{3}}} empty. This is different if {{{2}}} is defined and not empty!
If {{{1}}} and {{{2}}} are undefined, we successfully avoid different results for {{{3}}} undefined or empty.
If {{{2}}} is defined and not empty and {{{3}}} is undefined, we get {{{2}}} if {{{1}}} is undefined, but empty if {{{1}}} is empty!
Summarizing: there is one deviating result: if {{{2}}} is defined and not empty, we get this value if {{{1}}} and {{{3}}} 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
- This page was last modified on 28 April 2012, at 09:51.
- This page has been accessed 31 times.
New to the Research Wiki?
In the FamilySearch Research Wiki, you can learn how to do genealogical research or share your knowledge with others.
Learn More