Template:Yesno/doc
Jump to navigation
Jump to search
This is a documentation subpage for Template:Yesno (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 normalises an input to be a yes/no output.
Usage[edit source]
The template discerns five possible logical outputs depending on the first parameter (input if you will).
In its simplest usage these will all be either "yes" or "" (blank — nothing no characters).
- {{yesno|yes}} results in "yes" (also applies to "Yes", "YeS", etc, "Y", "y" and "1")
- {{yesno|no}} results in "" (also applies to "No", "NO", "nO", "N", "n" and "0")
- {{yesno}} results in ""
- {{yesno|¬}} results in ""
- {{yesno|purplemonkeydishwasher}} result "yes" (also applies to any other value not given above).
Each of these can be over-ridden.
- {{yesno|yes|yes=bacon}} results in "bacon" (also applies to "Yes", "YeS", etc, "Y", "y" and "1")
- {{yesno|no|no=ham}} results in "ham": (also applies to "No", "NO", "nO", "N", "n" and "0")
- {{yesno||blank=eggs}} results in "eggs"
- but {{yesno||no=ham}} results in "ham"
- and {{yesno||blank=eggs|no=ham}} results in "eggs"
- {{yesno|¬|¬=sausage}} results in "sausage"
- {{yesno|purplemonkeydishwasher|def=cup-of-tea}} results in "cup-of-tea" (also applies to any other value not given above).
- but {{yesno|purplemonkeydishwasher|yes=bacon}} results in "bacon"
- and {{yesno|purplemonkeydishwasher|def=cup-of-tea|yes=bacon}} results in "cup-of-tea"
This may be used (apparently perversely) thus:
- {{yesno|yes|yes=no|no=yes}} results in "no"
- {{yesno|no|yes=no|no=yes}} results in "yes"
This creates a logical inversion.
Full parameter list[edit source]
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 | | yes = | no = | blank= | ¬ = | def = }}
Overview of {{yesno}} logical values and their associated texts | ||||||
---|---|---|---|---|---|---|
Input parameter 1 ( )
|
In code | Logical return value | Default return text |
Return text when set:
|
Note | |
yes, y, 1* |
|
|
"yes" | "Pos" | * Case-insensitive (Y=y) | |
Some Text |
|
|
"yes" | "Def" | "Pos" when
| |
no, n, 0* |
|
|
"" | "Neg" | * Case-insensitive (N=n) | |
<blank> |
|
|
"" | "Blank" | "Neg" when
| |
1=<blank> |
|
|
"" | "Blank" | "Neg" when
| |
¬ |
|
|
"" | "Undefined" | ||
<omitted> |
|
|
"" | "Undefined" |
TemplateData[edit source]
This is the TemplateData documentation for the template used by the new VisualEditor.
Yesno <templatedata> {
"description": "This template normalises an input to be a yes/no output.", "params": { "1": { "label": "Value", "description": "The value to be evaluated", "type": "string", "required": true }, "yes": { "label": "Output on yes", "description": "Defines a value to output on yes", "type": "string", "required": false }, "no": { "label": "Output on no", "description": "Defines a value to output on no", "type": "string", "required": false }, "blank": { "label": "Output on blank input", "description": "Defines a value to output if blank input", "type": "string", "required": false }, "¬": { "label": "Output on ¬", "description": "Defines a value to output when input = ¬", "type": "string", "required": false }, "def": { "label": "Definite output", "description": "Defines the output when value = yes", "type": "string", "required": false } }
} </templatedata>