Module:Protection banner: Difference between revisions

simplify _substituteParameters
(make makeFullUrl a local helper function)
(simplify _substituteParameters)
Line 350: Line 350:
function Blurb:_substituteParameters(msg)
function Blurb:_substituteParameters(msg)
if not self._params then
if not self._params then
local params, parameterFuncs = {}, {}
local parameterFuncs = {}
setmetatable(params, {
__index = function (t, k)
local param
if parameterFuncs[k] then
param = parameterFuncs[k](self)
end
param = param or ''
params[k] = param
return param
end
})


parameterFuncs.CURRENTVERSION    = self._makeCurrentVersionParameter
parameterFuncs.CURRENTVERSION    = self._makeCurrentVersionParameter
Line 383: Line 372:
parameterFuncs.VANDAL            = self._makeVandalTemplateParameter
parameterFuncs.VANDAL            = self._makeVandalTemplateParameter
self._params = params
self._params = setmetatable({}, {
__index = function (t, k)
local param
if parameterFuncs[k] then
param = parameterFuncs[k](self)
end
param = param or ''
t[k] = param
return param
end
})
end
end
Anonymous user