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 | local parameterFuncs = {} | ||
parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter | parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter | ||
Line 383: | Line 372: | ||
parameterFuncs.VANDAL = self._makeVandalTemplateParameter | parameterFuncs.VANDAL = self._makeVandalTemplateParameter | ||
self._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 | ||