Difference between revisions of "Module:Yesno"

From Wikidot - Australian Business Wiki
Jump to navigation Jump to search
Module:Check_for_clobbered_parameters>MusikAnimal
(Undid revision 948472533 by [[Special:Contributions/w>Vogone|w>Vogone]] ([[User talk:w>Vogone|talk]]))
 
Module:Lang>Xaosflux
(add additional paramerters, "t", "f" - requested on talk - worked in sandbox /testcases)
Line 1: Line 1:
-- Function allowing for consistent treatment of boolean-like wikitext input.
+
{{<includeonly>safesubst:</includeonly>#switch: {{<includeonly>safesubst:</includeonly>lc: {{{1|¬}}} }}
-- It works similarly to the template {{yesno}}.
+
|no
 
+
|n
return function (val, default)
+
|f
-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you
+
|false
-- should replace "val:lower()" with "mw.ustring.lower(val)" in the
+
|off
-- following line.
+
|0        = {{{no|<!-- null -->}}}
val = type(val) == 'string' and val:lower() or val
+
|        = {{{blank|{{{no|<!-- null -->}}}}}}
if val == nil then
+
|¬        = {{{¬|}}}
return nil
+
|yes
elseif val == true
+
|y
or val == 'yes'
+
|t
or val == 'y'
+
|true
or val == 'true'
+
|on
or val == 't'
+
|1       = {{{yes|yes}}}
or val == 'on'
+
|#default = {{{def|{{{yes|yes}}}}}}
or tonumber(val) == 1
+
}}<noinclude>
then
+
{{Documentation}}
return true
+
</noinclude>
elseif val == false
 
or val == 'no'
 
or val == 'n'
 
or val == 'false'
 
or val == 'f'
 
or val == 'off'
 
or tonumber(val) == 0
 
then
 
return false
 
else
 
return default
 
end
 
end
 

Revision as of 03:15, 28 August 2020

Lua error: Internal error: The interpreter exited with status 127.