Difference between revisions of "Template:If either/doc"

From blackwiki
Jump to navigation Jump to search
imported>Droll
(tidied up)
imported>Frietjes
Line 4: Line 4:
 
:  "If either ('''a''' or) ('''b''') is true, (return ''first result'',) (else return ''second result'')."
 
:  "If either ('''a''' or) ('''b''') is true, (return ''first result'',) (else return ''second result'')."
  
This [[Help:Templates/Helper templates|helper template]] is designed to be used in other templates. It can help editors create template code that or self documenting. The major advantage of using this template over using the construct {{nowrap|{{plaincode|<nowiki>{{#if:{{{1|}}}{{{2|}}} |…}}</nowiki>}}}} is that if the first parameter is not empty then the second parameter is not evaluated.
+
This [[Help:Templates/Helper templates|helper template]] is designed to be used in other templates. It can help editors create template code that or self documenting. The major advantage of using this template over using the construct {{nowrap|<code><nowiki>{{#if:{{{1|}}}{{{2|}}} |…}}</nowiki></code>}} is that if the first parameter is not empty then the second parameter is not evaluated.
  
 
The "or" in the "'''a''' or '''b'''" above is [[Logical disjunction|inclusive]]: if both '''a''' <u>and</u> '''b''' are true, the template will return the ''first result''.
 
The "or" in the "'''a''' or '''b'''" above is [[Logical disjunction|inclusive]]: if both '''a''' <u>and</u> '''b''' are true, the template will return the ''first result''.
  
This template can also be used to replace the construct {{nowrap|{{plaincode|<nowiki>{{#if:</nowiki>'''a'''<nowiki> |true |{{#if:</nowiki>'''b'''<nowiki> |true |false}}}}</nowiki>}}}} (i.e. "if '''a''', then true; else if '''b''', then true; else false").
+
This template can also be used to replace the construct {{nowrap|<code><nowiki>{{#if:</nowiki>'''a'''<nowiki> |true |{{#if:</nowiki>'''b'''<nowiki> |true |false}}}}</nowiki></code>}} (i.e. "if '''a''', then true; else if '''b''', then true; else false").
 
<!----
 
<!----
 
The template's code is:
 
The template's code is:

Revision as of 15:58, 5 March 2015

{{if either (|a) (|b) (|first result) (|second result)}}
 "If either (a or) (b) is true, (return first result,) (else return second result)."

This helper template is designed to be used in other templates. It can help editors create template code that or self documenting. The major advantage of using this template over using the construct {{#if:{{{1|}}}{{{2|}}} |…}} is that if the first parameter is not empty then the second parameter is not evaluated.

The "or" in the "a or b" above is inclusive: if both a and b are true, the template will return the first result.

This template can also be used to replace the construct {{#if:a |true |{{#if:b |true |false}}}} (i.e. "if a, then true; else if b, then true; else false").

Examples

Script error: No such module "aligned table".

See also