Yesno module for processing of boolean-like wikitext input. It works similarly to the Yesno Wikipedia template. This module is a consistent Lua interface for wikitext input from templates.
Wikitext markup used by MediaWiki templates only permit string parameters like "0"
, "yes"
, "no"
etc. As Lua has a boolean primitive type, Yesno converts this wikitext into boolean output for Lua to process.
Documentation
Package function
yesno(value, default)
(function)- Yesno module for processing of boolean-like wikitext input.
- Parameters:
value
Wikitext boolean-style or Lua boolean input.- Truthy wikitext input (
'yes'
,'y'
,'1'
,'t'
or'on'
) producestrue
as output. - The string representations of Lua's true boolean value (
'true'
) also producestrue
. - Falsy wikitext input (
'no'
,'n'
,'0'
,'f'
or'off'
) producesfalse
as output. - The string representation of Lua's false boolean value (
'false'
) also producesfalse
. - Localised text meaning
'yes'
or'no'
also evaluate totrue
orfalse
respectively.
- Truthy wikitext input (
- (boolean|string|nil)
default
Output to return if the Yesnovalue
input is unrecognised. (boolean|string|nil; optional)
- Returns: Boolean output corresponding to
val
:- The strings documented above produce a boolean value.
- A
nil
value produces an output ofnil
. As this is falsy, additional logic may be needed to treat missing template parameters as truthy. - Unrecognised values return the
default
parameter. Blank strings are a key example of Yesno's unrecognised values and can evaluate totrue
if there is a default value.
- (boolean|nil)
See also