Jump to content

Module:Protection banner: Difference between revisions

allow reading wrapper templates and default arguments from the config page
(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 {}
if not cfg then
cfg = cfg or require('Module:Protection banner/config')
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)
if not getArgs then
getArgs = getArgs or require('Module:Arguments').getArgs
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


return p
return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.