This page is "edit" protected. The "sysop" right is required to "edit" this page.<ul class='mw-logevent-loglines'> <li data-mw-logid="608" data-mw-logaction="protect/protect" class="mw-logline-protect"> <a href="/index.php?title=Special:Log&amp;logid=608" title="Special:Log">21:48, 24 August 2023</a> <a href="/wiki/User:Deauthorized" class="mw-userlink" title="User:Deauthorized"><bdi>Deauthorized</bdi></a> <span class="mw-usertoollinks mw-changeslist-links"><span><a href="/wiki/User_talk:Deauthorized" class="mw-usertoollinks-talk" title="User talk:Deauthorized">talk</a></span> <span><a href="/wiki/Special:Contributions/Deauthorized" class="mw-usertoollinks-contribs" title="Special:Contributions/Deauthorized">contribs</a></span></span> protected <a href="/wiki/Module:Yesno" title="Module:Yesno">Module:Yesno</a> [Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite) <span class="comment">(Used in interface messages)</span> <span class="mw-logevent-actionlink">(<a href="/index.php?title=Module:Yesno&amp;action=history&amp;offset=20230824214834" title="Module:Yesno">hist</a>)</span> </li> </ul></ul>
This page is "move" protected. The "sysop" right is required to "move" this page.<ul class='mw-logevent-loglines'> <li data-mw-logid="608" data-mw-logaction="protect/protect" class="mw-logline-protect"> <a href="/index.php?title=Special:Log&amp;logid=608" title="Special:Log">21:48, 24 August 2023</a> <a href="/wiki/User:Deauthorized" class="mw-userlink" title="User:Deauthorized"><bdi>Deauthorized</bdi></a> <span class="mw-usertoollinks mw-changeslist-links"><span><a href="/wiki/User_talk:Deauthorized" class="mw-usertoollinks-talk" title="User talk:Deauthorized">talk</a></span> <span><a href="/wiki/Special:Contributions/Deauthorized" class="mw-usertoollinks-contribs" title="Special:Contributions/Deauthorized">contribs</a></span></span> protected <a href="/wiki/Module:Yesno" title="Module:Yesno">Module:Yesno</a> [Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite) <span class="comment">(Used in interface messages)</span> <span class="mw-logevent-actionlink">(<a href="/index.php?title=Module:Yesno&amp;action=history&amp;offset=20230824214834" title="Module:Yesno">hist</a>)</span> </li> </ul></ul>

Module:Yesno

From TotalFreedom Wiki
Revision as of 06:24, 5 September 2023 by Deauthorized (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Yesno/doc

-- Function allowing for consistent treatment of boolean-like wikitext input.
-- It works similarly to the template {{yesno}}.

return function (val, default)
	-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you
	-- should replace "val:lower()" with "mw.ustring.lower(val)" in the
	-- following line.
	val = type(val) == 'string' and val:lower() or val
	if val == nil then
		return nil
	elseif val == true 
		or val == 'yes'
		or val == 'y'
		or val == 'true'
		or val == 't'
		or val == 'on'
		or tonumber(val) == 1
	then
		return true
	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