Modul:Protection banner: Unterschied zwischen den Versionen
allow user-specified args to overwrite default args; updated from sandbox
(add a "TOOLTIPFRAGMENT" parameter, as we were having the same issues with commas in tooltips as we did with INTROBLURB and INTROFRAGMENT; also move the config module name to a global variable so that it's more obvious when updating) |
(allow user-specified args to overwrite default args; updated from sandbox) |
||
Zeile 892: | Zeile 892: | ||
function p.main(frame, cfg) | function p.main(frame, cfg) | ||
cfg = cfg or require(CONFIG_MODULE) | cfg = cfg or require(CONFIG_MODULE) | ||
-- Find default args, if any. | |||
local parentTitle = frame:getParent():getTitle() | local parentTitle = frame:getParent():getTitle() | ||
parentTitle = parentTitle:gsub('/sandbox$', '') | parentTitle = parentTitle:gsub('/sandbox$', '') | ||
local defaultArgs = cfg.wrappers[parentTitle] or {} | local defaultArgs = cfg.wrappers[parentTitle] or {} | ||
local | |||
-- Find user args, and use the parent frame if we are being called from a | |||
-- wrapper template. | |||
getArgs = getArgs or require('Module:Arguments').getArgs | |||
local userArgs = getArgs(frame, { | |||
parentOnly = defaultArgs, | |||
frameOnly = not defaultArgs | |||
}) | |||
-- Build the args table. User-specified args overwrite default args. | |||
local args = {} | |||
for k, v in pairs(defaultArgs) do | for k, v in pairs(defaultArgs) do | ||
args[k] = v | |||
end | |||
for k, v in pairs(userArgs) do | |||
args[k] = v | args[k] = v | ||
end | end |