Template:Yesno

From CryGaia Wiki
Revision as of 01:57, 12 June 2016 by Sojourner (talk | contribs) (Created page with "{{<includeonly>safesubst:</includeonly>#switch: {{<includeonly>safesubst:</includeonly>lc: {{{1|¬}}} }} |no |n |false |0 = {{{no|<!-- null -->}}} | = {{{b...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
[edit] [history] [purge] Documentation icon Template documentation

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:

  1. Yes: Case-insensitive forms of Yes, y, true, and 1;
  2. No: Case-insensitive forms of No, n, false, and 0;
  3. Nothing: When the input is defined but either contains no value or consists of whitespace character only; i.e. {{Yesno|}}
  4. Negation: When the input is either ¬ or entirely missing;
  5. 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:

  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|4=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|4=yes=bacon}} results in "cup of tea"