Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Template documentation[view] [edit] [history] [purge]

{{Yesno}} (or {{{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

The template distinguishes five different types of input, supplied on the first unnamed parameter:

  1. Yes: Case-insensitive forms of Yes, y, true, on, and 1; e.g. {{Yesno|yEs|yes=foo}}} → foo
  2. No: Case-insensitive forms of No, n, false, off, and 0; e.g. {{Yesno|off|no=bar}}} → bar
  3. Blank: When the input is defined but either contains no value or consists of whitespace characters only; i.e. {{Yesno||blank=bax}} or {{Yesno| |blank=qux}}} → bax and qux
  4. Negation: When the input is either ¬ (alt code 170) or entirely missing; i.e. {{Yesno|¬|¬=lorem}}} or {{Yesno|¬=ipsum}} → lorem and ipsum
  5. Anything else: e.g. {{Yesno|foo bar lorem ipsum|def=foo bar lorem ipsum}} → foo bar lorem ipsum

By default, the template returns "yes" in the 1st and 5th case but returns nil (blank, empty string) in the other cases (case 2, 3 and 4).

Customizing the output

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:

  1. 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"
  2. 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"
  3. 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|no=ham}} results in "eggs"
  4. Negation: Template returns the contents of |¬=, otherwise returns blank. For example:
    • {{yesno|¬|¬=sausage}} results in "sausage"
  5. 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|yes=bacon}} results in "cup of tea"

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]

Logical distinctions

See wikipedia docs, I am too lazy to re-format without making new templates!

https://en.wikipedia.org/wiki/Template:Yesno/doc#Logical_distinctions

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. <syntaxhighlight lang="wikitext" style="overflow: auto"> Definite output </syntaxhighlight>

See also

TemplateData

This template normalises an input to be a yes or nil output.

Template parameters

ParameterDescriptionTypeStatus
Input value1

The value to be evaluated

Stringsuggested
Output on yesyes

Specifies the output of the template when the input value is a case-insensitive forms of 'Yes', 'Y', 'True' or '1'

Stringoptional
Output on nono

Specifies the output of the template when the input value is a case-insensitive forms of 'No', 'N', 'False, or '0'

Stringoptional
Output on blank inputblank

Specifies the output of the template when the input value is defined but is either empty or contains nothing but whitespace character(s)

Stringoptional
Output on ¬¬

Specifies the output of the template when the input value is either '¬' (negation) or entirely missing (undefined)

Stringoptional
Definite outputdef

Specifies the output of the template when the input value is defined but not a form of 'yes', 'no', '1', '0', '¬' or blank

Stringoptional