Difference between revisions of "Module:Extension"

71 bytes added ,  19:04, 13 May 2020
Stop mangling the order of hooks: use the order given as parameters if parameters are provided, and alphabetical order if not
>Pppery
>Pppery
(Stop mangling the order of hooks: use the order given as parameters if parameters are provided, and alphabetical order if not)
Line 297: Line 297:
local argument = pframe.args["hook" .. index]
local argument = pframe.args["hook" .. index]
if argument and mw.text.trim(argument) ~= "" then
if argument and mw.text.trim(argument) ~= "" then
hooks[argument] = true
hooks[#hooks + 1] = mw.text.trim(argument)
foundLocalHooks = true
foundLocalHooks = true
else
else
Line 306: Line 306:
if not foundLocalHooks then
if not foundLocalHooks then
local data = getExtData()
local data = getExtData()
if data == nil then
if data == nil or data.Hooks == nil then
return ""
return ""
end
end
hooks = data.Hooks
for hook, _ in pairs(data.Hooks) do
if hooks == nil then
hooks[#hooks + 1] = hook
return ""
end
end
table.sort(hooks)
end
end
local first = true
local first = true
for hook, _ in pairs(hooks) do
for _, hook in ipairs(hooks) do
if first then
if first then
first = false
first = false
Anonymous user