Changes

Jump to: navigation, search

Module:Yesno

113 bytes added, 03:35, 18 April 2014
use the Lua string.lower function instead of mw.ustring.lower; this makes the function around 25x faster
-- 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 mw.ustring.val:lower(val) or val -- put in lower case if val == nil then return nil elseif val == false true or val == 'noyes' or val == 'ny' or val == 'falsetrue' or tonumber(val) == 0 1 then return falsetrue elseif val == true false or val == 'yesno' or val == 'yn' or val == 'truefalse' or tonumber(val) == 1 0 then return truefalse else return default end
end
Anonymous user

Navigation menu