Module:Arguments
Revision as of 17:41, 7 June 2022 by FnControlOption (talk | contribs) (FnControlOption changed the content model of the page Module:Arguments from "Scribunto" to "plain text")
local p = {}
function p.getArgs(frame, options)
options = options or {}
local metatable = {}
function metatable:__index(key)
local arg = frame.args[key]
if arg == nil and options.inherited then
local parent = frame:getParent()
arg = parent and parent.args[key] or nil
end
return arg
end
return setmetatable({}, metatable)
end
function p.makeInvokeFunc(func, options)
return function(frame)
local args = p.getArgs(frame, options)
if (options.passFrameParam) then
return func(frame, args)
end
return func(args)
end
end
return p