Template:Yesno/doc

From 'City of Adelaide' History and Genealogy Site
Jump to navigation Jump to search

{{#invoke:Message box|mbox}} {{#invoke:Message box|ombox}}

This template normalises an input to be a yes/no output.

Usage

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).

  1. {{yesno|yes}} results in "yes" (also applies to "Yes", "YeS", etc, "Y", "y" and "1")
  2. {{yesno|no}} results in "" (also applies to "No", "NO", "nO", "N", "n" and "0")
  3. {{yesno}} results in ""
  4. {{yesno|¬}} results in ""
  5. {{yesno|purplemonkeydishwasher}} result "yes" (also applies to any other value not given above).


Each of these can be over-ridden.

  1. {{yesno|yes|yes=bacon}} results in "bacon" (also applies to "Yes", "YeS", etc, "Y", "y" and "1")
  2. {{yesno|no|no=ham}} results in "ham": (also applies to "No", "NO", "nO", "N", "n" and "0")
  3. {{yesno||blank=eggs}} results in "eggs"
    1. but {{yesno||no=ham}} results in "ham"
    2. and {{yesno||blank=eggs|no=ham}} results in "eggs"
  4. {{yesno|¬|¬=sausage}} results in "sausage"
  5. {{yesno|purplemonkeydishwasher|def=cup-of-tea}} results in "cup-of-tea" (also applies to any other value not given above).
    1. but {{yesno|purplemonkeydishwasher|yes=bacon}} results in "bacon"
    2. 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

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
(<syntaxhighlight lang="text" enclose="none">1=</syntaxhighlight>)
In code Logical return value Default
return text
Return text when set:
<syntaxhighlight lang="text" enclose="none">yes=Pos</syntaxhighlight>
<syntaxhighlight lang="text" enclose="none">no=Neg</syntaxhighlight>
<syntaxhighlight lang="text" enclose="none">blank=Blank</syntaxhighlight>
<syntaxhighlight lang="text" enclose="none">¬=Undefined</syntaxhighlight>
<syntaxhighlight lang="text" enclose="none">def=Def</syntaxhighlight>
Note
yes, y, 1* <syntaxhighlight lang="text" enclose="none">{{yesno|yes}}</syntaxhighlight> <syntaxhighlight lang="text" enclose="none">yes by definition</syntaxhighlight> "yes" "Pos" * Case-insensitive (Y=y)
Some Text <syntaxhighlight lang="text" enclose="none">{{yesno|Some Text}}</syntaxhighlight> <syntaxhighlight lang="text" enclose="none">yes by default</syntaxhighlight> "yes" "Def" "Pos" when <syntaxhighlight lang="text" enclose="none">def=<omitted></syntaxhighlight>
no, n, 0* <syntaxhighlight lang="text" enclose="none">{{yesno|no}}</syntaxhighlight> <syntaxhighlight lang="text" enclose="none">no by definition</syntaxhighlight> "" "Neg" * Case-insensitive (N=n)
<blank> <syntaxhighlight lang="text" enclose="none">{{yesno|}}</syntaxhighlight> <syntaxhighlight lang="text" enclose="none">blank</syntaxhighlight> "" "Blank" "Neg" when <syntaxhighlight lang="text" enclose="none">blank=<omitted></syntaxhighlight>
1=<blank> <syntaxhighlight lang="text" enclose="none">{{yesno|1=}}</syntaxhighlight> <syntaxhighlight lang="text" enclose="none">blank</syntaxhighlight> "" "Blank" "Neg" when <syntaxhighlight lang="text" enclose="none">blank=<omitted></syntaxhighlight>
¬ <syntaxhighlight lang="text" enclose="none">{{yesno|¬}}</syntaxhighlight> <syntaxhighlight lang="text" enclose="none">¬</syntaxhighlight> "" "Undefined"
<omitted> <syntaxhighlight lang="text" enclose="none">{{yesno}}</syntaxhighlight> <syntaxhighlight lang="text" enclose="none">¬</syntaxhighlight> "" "Undefined"



TemplateData

This is the TemplateData documentation for this template used by VisualEditor and other tools.

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>