Template:Yesno/doc
- The following is adapted from https://en.wikipedia.org/w/index.php?title=Template%3AYesno%2Fdoc&action=edit
{{Yesno}}
evaluates any input and produces a normalized yes or nil output, based on the content of the input and several configurable options. It is not used in article prose, but in coding complex templates.
Usage[edit]
This template accepts 5 types of input:
- Yes: Case-insensitive forms of
Yes
,y
,true
,on
, and1
; e.g.{{Yesno|yEs}}
→ yes - No: Case-insensitive forms of
No
,n
,false
,off
, and0
; e.g.{{Yesno|nO}}
→- Contrary to the wikipedia version, this template returs "yes" to
false
andoff
.
- Contrary to the wikipedia version, this template returs "yes" to
- Nothing: When the input is defined but either contains no value or consists of whitespace character only; i.e.
{{Yesno|}}
or{{Yesno| }}
→ - Negation: When the input is either
¬
([alt code] 170) or entirely missing; i.e.{{Yesno|¬}}
or{{Yesno}}
→ - Anything else: e.g.
{{Yesno|Purple monkey dish washer}}
→ yes
By default, the template returns "yes" in the first and last case but returns nil (blank, empty string) in the other cases.
Customizing the output[edit]
Template's default output can be customized with five named parameters, respectively: |yes=
, |no=
, |blank=
, |¬=
and |def=
. If these parameters are specified, the template response is as follows:
- Yes: Template returns the contents of
|yes=
, otherwise returns "yes". For example: - No: Template returns the contents of
|no=
, otherwise returns blank. For example: - Nothing: Template returns the contents of
|blank=
, or of|no=
in absence of the former; otherwise, returns blank. - 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".
For the named parameters, use of a blank value is not the same as omitting the parameter. A blank named parameter tells the template that the customized return value is blank. For example:
{{yesno|purple monkey dish washer}}
results in "yes"{{yesno|purple monkey dish washer|def=}}
results in "" [blank]
Full parameter list[edit]
Unnamed parameter 1= the input value to be evaluated. The other parameters (all named, all optional), are the return values for their respective logical outcome. When set, each one overrules their default return value.
{{yesno
| Input value
| yes: Output on yes
| no: Output on no
| blank: Output on blank input
| ¬: Output on ¬
| def: Definite output
} }