Difference between revisions of "Module:Arguments"
Jump to navigation
Jump to search
m (Added makeInvokeFunc) |
m (Added passFrameParam option) |
||
(One intermediate revision by the same user not shown) | |||
Line 17: | Line 17: | ||
function p.makeInvokeFunc(func, options) | function p.makeInvokeFunc(func, options) | ||
return function(frame) | return function(frame) | ||
− | local args = getArgs(frame, options) | + | local args = p.getArgs(frame, options) |
+ | if (options.passFrameParam) then | ||
+ | return func(frame, args) | ||
+ | end | ||
return func(args) | return func(args) | ||
end | end |
Revision as of 18:10, 7 May 2017
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