Template:Yesno
Jump to navigation
Jump to search
This template evaluates any input and produces a normalized yes or no, based on the content of the input and several configurable options. It is not used in article prose, but in coding complex templates.
Usage
The template distinguishes five different types of input, supplied on the first unnamed parameter:
- Yes: Case-insensitive forms of
Yes
,y
,
true
, and1
; - No: Case-insensitive forms of
No
,n
,false
, and0
; - Nothing: When the input is defined but either contains no value or consists of whitespace character only; i.e.
{{Yesno|}}
- Negation: When the input is either
¬
or entirely missing; - Anything else: e.g.
By default, the template returns "yes" in the first and last case but returns blank in the other cases.
Customizing the output
Template's default output can be customized with five named parameters. If these parameters are specified, the template response is as follows:
- Yes: Template returns the contents of yes=, otherwise returns "yes". For example:
- {{yesno|y|yes=Yeah}} results in "Yeah"
- {{yesno|y|yes=bacon}} results in "bacon"
- No: Template returns the contents of no=, otherwise returns blank. For example:
- {{yesno|n|no=Nay}} results in "Nay"
- {{yesno|n|no=ham}} results in "ham"
- Nothing: Template returns the contents of blank=, or of no- in absence of the former; otherwise, returns blank.
- {{yesno||blank=eggs}} results in "eggs"
- {{yesno||no=ham}} results in "ham"
- {{yesno||blank=eggs|4=no=ham}} results in "eggs"
- Negation: Template returns the contents of ¬=, otherwise returns blank. For example:
- {{yesno|¬|¬=sausage}} results in "sausage"
- Anything else: Template returns the contents of def=, or of yes= in absence of the former; otherwise, returns "yes".
- {{yesno|purple monkey dish washer|def=cup of tea}} results in "cup of tea"
- {{yesno|purple monkey dish washer|yes=bacon}} results in "bacon"
- {{yesno|purple monkey dish washer|def=cup of tea|4=yes=bacon}} results in "cup of tea"
The above documentation is transcluded from Template:Yesno/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories and interwikis to the /doc subpage. Subpages of this template. |