Changes

Jump to: navigation, search

Module:Yesno

552 bytes removed, 22:54, 3 October 2018
m
1 revision imported
local p = -- Function allowing for consistent treatment of boolean-like wikitext input.-- It works similarly to the template {{yesno}}.
return function p.yesno(frameval, default --If your wiki uses non- defaults local retvals = { yes = ascii characters for any of "yes", "no = "",etc., you [ -- should replace "¬val:lower()"] = with "mw.ustring.lower(val)"in the }  -- Allow arguments to override defaultsfollowing line. -- 'any' tracks the presence of any arguments at all. local args val = frame.args local any = false for k,v in pairstype(argsval) do any = true retvals[k] = v end -- If there are no arguments, try 'string' and get them from the parent frame.val:lower() or val if any val == false nil then local pframe = frame:getParent() return nil args elseif val = pframe.args for k,v in pairs(args) do any = true retvals[k] or val = v end end   val = args[1]'yes'  -- First deal with the case if val is nil or "¬", then deal with other cases. if val == nil 'y' or val == '¬true' then return retvals[ or val == '¬t'] end  or val = val:lower() -- Coerce to blank if nil; make lowercase. val = val:match'^%s*(.*%S)on' or '' -- Trim whitespace.  if tonumber(val ) == '' 1 then return retvals['blank'] or retvals['no']true elseif val == 'n' false or val == 'no' or val == '0n' then return retvals['no'] elseif or val == 'yfalse' or val == 'yesf' or val == '1off' or retvals['def'] tonumber(val) == nil 0 then return retvals['yes']false else return retvals['def']default end
end
 
return p

Navigation menu