<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://help.gulfstatesflood.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AYesno%2Fdoc</id>
	<title>Module:Yesno/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://help.gulfstatesflood.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AYesno%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://help.gulfstatesflood.com/mediawiki/index.php?title=Module:Yesno/doc&amp;action=history"/>
	<updated>2026-04-06T02:35:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.0</generator>
	<entry>
		<id>https://help.gulfstatesflood.com/mediawiki/index.php?title=Module:Yesno/doc&amp;diff=6504&amp;oldid=prev</id>
		<title>WikiAdmin: Created page with &quot;{{Documentation subpage}} &lt;!-- Documentation here --&gt;  This module provides a consistent interface for processing boolean or boolean-style string input. While Lua allows the &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; boolean values, wikicode templates can only express boolean values through strings such as &quot;1&quot;, &quot;0&quot;, &quot;yes&quot;, &quot;no&quot;, etc. This module processes these kinds of strings and turns them into boolean input for Lua to process. It also returns &lt;code&gt;nil&lt;/code&gt; values as...&quot;</title>
		<link rel="alternate" type="text/html" href="https://help.gulfstatesflood.com/mediawiki/index.php?title=Module:Yesno/doc&amp;diff=6504&amp;oldid=prev"/>
		<updated>2024-12-27T18:22:27Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Documentation subpage}} &amp;lt;!-- Documentation here --&amp;gt;  This module provides a consistent interface for processing boolean or boolean-style string input. While Lua allows the &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; boolean values, wikicode templates can only express boolean values through strings such as &amp;quot;1&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;yes&amp;quot;, &amp;quot;no&amp;quot;, etc. This module processes these kinds of strings and turns them into boolean input for Lua to process. It also returns &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; values as...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Documentation subpage}}&lt;br /&gt;
&amp;lt;!-- Documentation here --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This module provides a consistent interface for processing boolean or boolean-style string input.&lt;br /&gt;
While Lua allows the &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; boolean values, wikicode templates can only express boolean values through strings such as &amp;quot;1&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;yes&amp;quot;, &amp;quot;no&amp;quot;, etc.&lt;br /&gt;
This module processes these kinds of strings and turns them into boolean input for Lua to process.&lt;br /&gt;
It also returns &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; values as &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;, to allow for distinctions between &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;.&lt;br /&gt;
The module also accepts other Lua structures as input, i.e. booleans, numbers, tables, and functions.&lt;br /&gt;
If it is passed input that it does not recognize as boolean or &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;, it is possible to specify a default value to return.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
yesno(value, default)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; is the value to be tested.&lt;br /&gt;
Boolean input or boolean-style input (see below) always evaluates to either &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; always evaluates to &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;.&lt;br /&gt;
Other values evaluate to &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
First, load the module. Note that it can only be loaded from other Lua modules, not from normal wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local yesno = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some input values always return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, and some always return &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; values always return &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- These always return true:&lt;br /&gt;
yesno(&amp;#039;yes&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;y&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;true&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;t&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;1&amp;#039;)&lt;br /&gt;
yesno(1)&lt;br /&gt;
yesno(true)&lt;br /&gt;
&lt;br /&gt;
-- These always return false:&lt;br /&gt;
yesno(&amp;#039;no&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;n&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;false&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;f&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;0&amp;#039;)&lt;br /&gt;
yesno(0)&lt;br /&gt;
yesno(false)&lt;br /&gt;
&lt;br /&gt;
-- A nil value always returns nil:&lt;br /&gt;
yesno(nil)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
String values are converted to lower case before they are matched:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- These always return true:&lt;br /&gt;
yesno(&amp;#039;Yes&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;YES&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;yEs&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;Y&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;tRuE&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
-- These always return false:&lt;br /&gt;
yesno(&amp;#039;No&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;NO&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;nO&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;N&amp;#039;)&lt;br /&gt;
yesno(&amp;#039;fALsE&amp;#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can specify a default value if &amp;lt;code&amp;gt;yesno&amp;lt;/code&amp;gt; receives input other than that listed above.&lt;br /&gt;
If you don&amp;#039;t supply a default, the module will return &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; for these inputs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- These return nil:&lt;br /&gt;
yesno(&amp;#039;foo&amp;#039;)&lt;br /&gt;
yesno({})&lt;br /&gt;
yesno(5)&lt;br /&gt;
yesno(function() return &amp;#039;This is a function.&amp;#039; end)&lt;br /&gt;
&lt;br /&gt;
-- These return true:&lt;br /&gt;
yesno(&amp;#039;foo&amp;#039;, true)&lt;br /&gt;
yesno({}, true)&lt;br /&gt;
yesno(5, true)&lt;br /&gt;
yesno(function() return &amp;#039;This is a function.&amp;#039; end, true)&lt;br /&gt;
&lt;br /&gt;
-- These return &amp;quot;bar&amp;quot;:&lt;br /&gt;
yesno(&amp;#039;foo&amp;#039;, &amp;#039;bar&amp;#039;)&lt;br /&gt;
yesno({}, &amp;#039;bar&amp;#039;)&lt;br /&gt;
yesno(5, &amp;#039;bar&amp;#039;)&lt;br /&gt;
yesno(function() return &amp;#039;This is a function.&amp;#039; end, &amp;#039;bar&amp;#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
Note that the blank string also functions this way:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
yesno(&amp;#039;&amp;#039;)        -- Returns nil.&lt;br /&gt;
yesno(&amp;#039;&amp;#039;, true)  -- Returns true.&lt;br /&gt;
yesno(&amp;#039;&amp;#039;, &amp;#039;bar&amp;#039;) -- Returns &amp;quot;bar&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although the blank string usually evaluates to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; in wikitext, it evaluates to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; in Lua.&lt;br /&gt;
This module prefers the Lua behaviour over the wikitext behaviour.&lt;br /&gt;
If treating the blank string as &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; is important for your module, you will need to remove blank arguments at an earlier stage of processing.&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
&amp;lt;!-- Template categories/interwikis here --&amp;gt;&lt;br /&gt;
[[Category:Modules]]&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>WikiAdmin</name></author>
	</entry>
</feed>