<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ro">
	<id>https://insemn.org/signify/index.php?action=history&amp;feed=atom&amp;title=Modul%3AYesno%2Fdoc</id>
	<title>Modul:Yesno/doc - Revizia istoricului</title>
	<link rel="self" type="application/atom+xml" href="https://insemn.org/signify/index.php?action=history&amp;feed=atom&amp;title=Modul%3AYesno%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://insemn.org/signify/index.php?title=Modul:Yesno/doc&amp;action=history"/>
	<updated>2026-04-21T18:02:39Z</updated>
	<subtitle>Istoricul versiunilor pentru această pagină din wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://insemn.org/signify/index.php?title=Modul:Yesno/doc&amp;diff=299&amp;oldid=prev</id>
		<title>Adminsorg: 1 versiune importată</title>
		<link rel="alternate" type="text/html" href="https://insemn.org/signify/index.php?title=Modul:Yesno/doc&amp;diff=299&amp;oldid=prev"/>
		<updated>2024-10-26T07:02:34Z</updated>

		<summary type="html">&lt;p&gt;1 versiune importată&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ro&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Versiunea anterioară&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Versiunea de la data 26 octombrie 2024 10:02&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ro&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(Nicio diferență)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Adminsorg</name></author>
	</entry>
	<entry>
		<id>https://insemn.org/signify/index.php?title=Modul:Yesno/doc&amp;diff=298&amp;oldid=prev</id>
		<title>WikiPedia&gt;Od1n: /* Handling nil results */ added better suggestions</title>
		<link rel="alternate" type="text/html" href="https://insemn.org/signify/index.php?title=Modul:Yesno/doc&amp;diff=298&amp;oldid=prev"/>
		<updated>2024-09-07T08:06:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Handling nil results: &lt;/span&gt; added better suggestions&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pagină nouă&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{used in system}}&lt;br /&gt;
{{Module rating|protected}}&lt;br /&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;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;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;. The module also accepts other Lua structures as input, i.e. booleans, numbers, tables, and functions. If it is passed input that it does not recognise 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;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;yesno(value, default)&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. 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;. 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;
&lt;br /&gt;
First, load the module. Note that it can only be loaded from other Lua modules, not from normal wiki pages. For normal wiki pages you can use {{tl|yesno}} instead.&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;. &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;on&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;off&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;
yesno()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
String values are converted to lower case before they are matched:&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;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;
===Undefined input (&amp;#039;foo&amp;#039;)===&lt;br /&gt;
You can specify a default value if yesno receives input other than that listed above. 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(nil)&lt;br /&gt;
yesno(&amp;#039;foo&amp;#039;)&lt;br /&gt;
yesno({})&lt;br /&gt;
yesno(5)&lt;br /&gt;
yesno(&amp;#039;&amp;#039;)&lt;br /&gt;
yesno(function() return &amp;#039;This is a function.&amp;#039; end)&lt;br /&gt;
yesno(nil, true)&lt;br /&gt;
yesno(nil, &amp;#039;bar&amp;#039;)&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(&amp;#039;&amp;#039;, 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(&amp;#039;&amp;#039;, &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;
&lt;br /&gt;
Although the empty string usually evaluates to false in wikitext, it evaluates to true in Lua. This module prefers the Lua behaviour over the wikitext behaviour. If treating the empty string as false is important for your module, you will need to convert empty strings to a value that evaluates to false before passing them to this module. In the case of arguments received from wikitext, this can be done by using [[Module:Arguments]].&lt;br /&gt;
&lt;br /&gt;
===Handling nil results===&lt;br /&gt;
By definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
yesno(nil)         -- Returns nil.&lt;br /&gt;
yesno(&amp;#039;foo&amp;#039;)       -- Returns nil.&lt;br /&gt;
yesno(nil, true)   -- Returns nil.&lt;br /&gt;
yesno(nil, false)  -- Returns nil.&lt;br /&gt;
yesno(&amp;#039;foo&amp;#039;, true) -- Returns true.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the binary &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; inline&amp;gt;true/false&amp;lt;/syntaxhighlight&amp;gt;-only values, use code like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
myvariable = yesno(value or false) -- When value is nil, result is false.&lt;br /&gt;
myvariable = yesno(value or true)  -- When value is nil, result is true. (XXX: when value is false, result is true...)&lt;br /&gt;
myvariable = yesno(&amp;#039;foo&amp;#039;) or false  -- Unknown string returns nil, result is false.&lt;br /&gt;
myvariable = yesno(&amp;#039;foo&amp;#039;, true) or false  -- Default value (here: true) applies, result is true.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better suggestions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local myvariable = yesno(value)&lt;br /&gt;
if myvariable == nil then -- value is nil or an unrecognized string&lt;br /&gt;
    myvariable = true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- more efficient when value is nil, but more verbose&lt;br /&gt;
-- (note the default result has to be written twice)&lt;br /&gt;
local myvariable&lt;br /&gt;
if value == nil then&lt;br /&gt;
    myvariable = true&lt;br /&gt;
else&lt;br /&gt;
    myvariable = yesno(value, true)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&amp;lt;includeonly&amp;gt;{{sandbox other||&lt;br /&gt;
[[Category:Lua metamodules]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Module documentation pages]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>WikiPedia&gt;Od1n</name></author>
	</entry>
</feed>