Changes

Module:Yesno

145 bytes added, 9 years ago
recognise "t" for true and "f" for false, per request
-- 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 val == 't' or tonumber(val) == 0 1 then return falsetrue elseif val == true false or val == 'yesno' or val == 'yn' or val == 'truefalse' or val == 'f' or tonumber(val) == 1 0 then return truefalse else return default end
end
Anonymous user