Module:Sandbox/Toohool Explained
local p =
local function trim(s) return mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1") end
function p.makeWrapper(func, opts) opts = opts or local nullableArgNames = for i, v in ipairs(opts.nullable or) do nullableArgNames[v] = true end local noTrimArgNames = for i, v in ipairs(opts.notrim or opts.noTrim or) do noTrimArgNames[v] = true end return function(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 local args = setmetatable(args,) return func(args) endend
return p