Jump to content

Module:Protection banner: Difference between revisions

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)
Line 892: Line 892:


function p.main(frame, cfg)
function p.main(frame, cfg)
getArgs = getArgs or require('Module:Arguments').getArgs
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 args = getArgs(frame, {parentOnly = defaultArgs and true})
 
-- 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
Cookies help us deliver our services. By using our services, you agree to our use of cookies.