Module:Yesno
Documentation for this module may be created at Module:Yesno/doc
local p = {}
-- Import yesno function safely
local yesno
local success, result = pcall(require, 'Module:Yesno')
if success then
yesno = result._yesno -- Use the internal function directly
else
-- Fallback function if Module:Yesno is not available
yesno = function(val, default)
if val == nil then return default end
if type(val) == "string" then
val = mw.text.trim(val:lower())
end
if val == 'yes' or val == 'y' or val == 'true' or val == '1' or val == true then
return true
elseif val == 'no' or val == 'n' or val == 'false' or val == '0' or val == false then
return false
else
return default
end
end
end
-- Then in your template function:
function p.infobox(frame)
-- Use yesno like this:
local autoheaders = yesno(frame.args.autoheaders, false)
-- or
local decat = yesno(frame.args.decat, false)
-- NOT: require('Module:Yesno').yesno(frame)
end
return p