Difference between revisions of "Module:Arguments"
Jump to navigation
Jump to search
(Created page with "local p = {} function p.getArgs(frame, options) options = options or {} local metatable = {} function metatable:__index(key) local arg = frame.args[key] ...") |
(FnControlOption changed the content model of the page Module:Arguments from "plain text" to "Scribunto") Tag: content model change |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 13: | Line 13: | ||
end | end | ||
return setmetatable({}, metatable) | 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 | end | ||
return p | return p |
Latest revision as of 17:42, 7 June 2022
Documentation for this module may be created at Module:Arguments/doc
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