Module:Protection banner: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(use pipes as separators instead of hyphens for the protection category keys and validate reasons when we create the protection object to make sure they don't contain pipes)
(allow reading wrapper templates and default arguments from the config page)
Line 783: Line 783:
function p._main(args, cfg, title)
function p._main(args, cfg, title)
args = args or {}
args = args or {}
cfg = cfg or require('Module:Protection banner/config')
if not cfg then
cfg = require('Module:Protection banner/config')
end


-- Initialise the protection object and check for errors
-- Initialise the protection object and check for errors
Line 826: Line 824:
end
end


function p.main(frame)
function p.main(frame, cfg)
getArgs = getArgs or require('Module:Arguments').getArgs
if not getArgs then
getArgs = require('Module:Arguments').getArgs
cfg = cfg or require('Module:Protection banner/config')
local defaultArgs = cfg.wrappers[frame:getParent():getTitle()]
local args = getArgs(frame, {parentOnly = defaultArgs and true})
for k, v in pairs(defaultArgs or {}) do
args[k] = v
end
end
local args = getArgs(frame)
return p._main(args, cfg)
return p._main(args)
end
end