Module:Utils
Revision as of 17:41, 21 November 2013 by Moussekateer (talk | contribs) (Lowercase all parameter names)
Documentation for this module may be created at Module:Utils/doc
local util = {} function util.get_args(frame) local origArgs if frame == mw.getCurrentFrame() then -- We're being called via #invoke. If the invoking template passed any args, use -- them. Otherwise, use the args that were passed into the template. origArgs = frame:getParent().args for k, v in pairs(frame.args) do origArgs = frame.args break end else -- We're being called from another module or from the debug console, so assume -- the args are passed in directly. origArgs = frame end -- ParserFunctions considers the empty string to be false, so to preserve the previous -- behavior of the template, change any empty arguments to nil, so Lua will consider -- them false too. local args = {} for k, v in pairs(origArgs) do if v ~= '' then -- parameter names should be case-insensitive args[string.lower(k)] = v end end return args end return util