Anonymous user
Module:Arguments: Difference between revisions
return a table rather than a function, improve the comments
(create argument-processing module) |
(return a table rather than a function, improve the comments) |
||
Line 1:
-- This module provides easy processing of arguments passed to Scribunto from #invoke.
-- It is intended for use by other Lua modules, and should not be called from #invoke directly.
local arguments = {}
local function getArguments(frame, options)▼
options = type(options) == 'table' and options or {}
-- Get the arguments from the frame object if available. If the frame object is not available, we are being called
-- from another Lua module or from the debug console, so assume arguments are passed directly in.
local fargs, pargs
if frame == mw.getCurrentFrame() then
Line 31 ⟶ 36:
end
-- Use a user-generated functions to tidy the values if specified.
local valueFunc = options.valueFunc
if valueFunc then
Line 54 ⟶ 60:
end
-- Set the order of precedence of frame args and parent args.
local firstArgs, secondArgs = fargs, pargs
if options.parentFirst then
Line 59 ⟶ 66:
end
-- Define metatable behaviour.
metatable.__index = function (t, key)
local val = metaArgs[key]
Line 99 ⟶ 107:
end
return
|