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

From blackwiki
Jump to navigation Jump to search
imported>Droll
(typo)
imported>Vanisaac
m (→‎See also: clean up per WP:CAT#T and WP:AWBREQ add template:Sandbox other)
 
(14 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
{{Documentation subpage}}
 
{{Documentation subpage}}
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
__NOTOC__
+
__NOTOC____NOEDITSECTION__
===Purpose===
 
This simple template is designed to facilitate template coding and should only be used in templates.
 
===Function===
 
The functionality is simple. If '''a''' and '''b''' then '''x''' else '''y'''.
 
  
I both ''a'' and ''b'' are defined then the template resolves to '''x'''.
+
This [[Help:Templates/Helper templates|helper template]] is designed to be used in other templates. It can help editors create template code that is self documenting.
  
If either ''a'' or ''b'' are undefined then the template resolves to '''y'''.
+
=== Usage ===
 +
If '''a''' and '''b''' then true.
  
:<nowiki>{{if2 | a | b | x | y}}</nowiki>  --> {{if2|a|b|x|y}}
+
If '''a''' nor '''b''' then false.
  
:<nowiki>{{if2 | a | &ensp; | x | y}}</nowiki> --> {{if2|a||x|y}}
+
If '''a''' or '''b''' then false.
It can be used to replace the construct:
 
:<nowiki>{{#if: a | {{#if: b | x | y }}}}</nowiki>
 
  
 +
It can be used to replace the construct: <code><nowiki>{{#if:a|{{#if:b|true|false}}|false}}</nowiki></code>
  
===See also===
+
=== Examples ===
*{{tl|ifempty}}
 
<noinclude>
 
<!-- PLEASE ADD CATEGORIES AND
 
INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
  
 +
<code><nowiki>{{if both| a | b |true|false}}</nowiki> → {{if both| a | b |true|false}}</code>
  
</noinclude>
+
<code><nowiki>{{if both| a | |true|false}}</nowiki> → {{if both| | b |true|false}}</code>
 +
 
 +
<code><nowiki>{{if both| | b |true|false}}</nowiki> → {{if both| | b |true|false}}</code>
 +
 
 +
<code><nowiki>{{if both| |  |true|false}}</nowiki> → {{if both| |  |true|false}}</code>
 +
 
 +
=== See also ===
 +
* {{tl|if either}}
 +
* {{tl|if empty}}
 +
* {{tl|if all}}
 +
 
 +
<includeonly>{{Sandbox other||
 +
<!-- CATEGORIES GO HERE -->
 +
[[Category:If-then-else templates]]
 +
 
 +
<!-- INTERWIKIS GO HERE -->
 +
 
 +
}}</includeonly>

Latest revision as of 17:17, 25 April 2020


This helper template is designed to be used in other templates. It can help editors create template code that is self documenting.

Usage

If a and b then true.

If a nor b then false.

If a or b then false.

It can be used to replace the construct: {{#if:a|{{#if:b|true|false}}|false}}

Examples

{{if both| a | b |true|false}} → true

{{if both| a | |true|false}} → false

{{if both| | b |true|false}} → false

{{if both| | |true|false}} → false

See also