Template:Yesno

From the RuneScape Wiki, the wiki for all things RuneScape
Jump to navigation Jump to search
Template documentation
This documentation is transcluded from Template:Yesno/doc. [edit] [history] [purge]

Tests an input for a truthy or falsy value. This is the pure wikitext template version - for module use, use Module:Yesno.

Truthy and falsy values

The following values are considered 'truthy' (case insensitive):

  • yes
  • y
  • true
  • 1

The following values are considered 'falsy' (case insensitive):

  • no
  • n
  • false
  • 0

The following is a special value that will output the same as if the input is not provided at all (i.e. {{yesno}}):

  • ¬

As this is made with pure wikitext, all values are strings.

Usage

Basic use

{{yesno|value}} - Test the value - outputs 1 if truthy and nothing (empty string) if falsy or missing.

This template is generally meant to be used by other templates, so using a like {{#if:{{yesno|{{{value|}}}}}|output if truthy|output if falsey}} is more likely.

Examples
  • {{yesno|true}} - 1
  • {{yesno|yes}} - 1
  • {{yesno|n}} -
  • {{yesno|}} -
  • {{yesno}} -
  • {{yesno|hello}} - 1

Advanced use

Split on to multiple lines for clarity, but not necessary in use.

{{yesno
|value
|true=output if truthy - default 1
|false=output if falsy - default empty string
|blank=output if the value is defined and blank - default the same as false
|def=output if the value is defined and none of the above - default the same as true
|¬=output if the value is not defined - default empty string (does not fallback to false)
}}

The output of the template can be changed for all of the possible states of the parameter.

Examples
  • {{yesno|true|true=truthy :)|false=falsy :(|blank=blank :|def=defined :X|¬=undefined :?}} - truthy :)
  • {{yesno|yes|true=truthy :)|false=falsy :(|blank=blank :|def=defined :X|¬=undefined :?}} - truthy :)
  • {{yesno|n|true=truthy :)|false=falsy :(|blank=blank :|def=defined :X|¬=undefined :?}} - falsy :(
  • {{yesno||true=truthy :)|false=falsy :(|blank=blank :|def=defined :X|¬=undefined :?}} - blank :
  • {{yesno|true=truthy :)|false=falsy :(|blank=blank :|def=defined :X|¬=undefined :?}} - undefined :?
  • {{yesno|hello|true=truthy :)|false=falsy :(|blank=blank :|def=defined :X|¬=undefined :?}} - defined :X
  • fallback to truthy: {{yesno|hello|true=truthy :)|false=falsy :(|¬=undefined :?}} - truthy :)
  • fallback to falsy: {{yesno||true=truthy :)|false=falsy :(|¬=undefined :?}} - falsy :(

By changing the values, one could make a construct such as {{#expr: {{GEP|Fire rune}} * {{yesno|{{{biggermultiplier|}}}|true=50|false=2}} }}

Do also remember the difference between {{yesno|{{{value}}}}} and {{yesno|{{{value|}}}}} (adding a default to the value param with |). If the value parameter is not provided, in the former case yesno would receive the literal string {{{value}}}, which is truthy; in the latter case yesno receives the empty string which is falsy.

Note on ¬

If the input to yesno is exactly ¬, the output is the same as if the parameter is not defined at all. This only applies for the exact string ¬; if a string contains it and other characters, it is fine.

  • {{yesno|¬|true=truthy :)|false=falsy :(|blank=blank :|def=defined :X|¬=undefined :?}} - undefined :?
  • {{yesno|ab¬|true=truthy :)|false=falsy :(|blank=blank :|def=defined :X|¬=undefined :?}} - defined :X
  • {{yesno|¬cd|true=truthy :)|false=falsy :(|blank=blank :|def=defined :X|¬=undefined :?}} - defined :X

Template data

Show/hide template's data

The following information is used by extensions and applications, such as VisualEditor, to help users implement this template onto pages. Please ensure that it is up-to-date.

Normalizes boolean template arguments.

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Input1

The value to normalize

Auto value
{{{parameter|¬}}}
Stringrequired
Truthy outputtrue

Output on a truthy value (e.g.: case‑insensitive 'yes', 'y', 'true', or '1')

Default
1
Stringoptional
Falsy outputfalse

Output on a falsy value (e.g.: case‑insensitive 'no', 'n', 'false', or '0')

Stringoptional
Blank outputblank

Output when the input parameter is defined but its value is empty

Default
{{{false}}}
Stringoptional
Undefined output¬

Output when the input parameter is either '¬' or entirely missing (undefined)

Auto value
¬
Stringoptional
Definite outputdef

Output when the input value is specified but isn't any of the preceding values

Default
{{{true}}}
Stringoptional

Based on wikipedia:commons:Data:Templatedata/yesno.tab

See also