Модуль:Сущность: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 135: | Строка 135: | ||
if not switchKeyToTemplates[sw][key] then | if not switchKeyToTemplates[sw][key] then | ||
switchKeyToTemplates[sw][key] = {} | switchKeyToTemplates[sw][key] = {} | ||
table.insert(switchKeyOrder[sw], key) | table.insert(switchKeyOrder[sw], key) | ||
end | end | ||
| Строка 144: | Строка 143: | ||
end | end | ||
local tplStr = makeTplCall(tplPath, sw, key, id, extra) | local tplStr = makeTplCall(tplPath, sw, key, id, extra) | ||
local priority = 1 | |||
if parsed and parsed.priority ~= nil then | |||
{ kind = kind, name = name, pathName = pathName, tplPath = tplPath }) | if type(parsed.priority) == "number" then | ||
priority = parsed.priority | |||
else | |||
local pnum = tonumber(parsed.priority) | |||
if pnum then priority = pnum end | |||
end | |||
end | |||
local entry = { | |||
tpl = tplStr, | |||
source = { kind = kind, name = name, pathName = pathName, tplPath = tplPath }, | |||
priority = priority, | |||
idx = #switchKeyToTemplates[sw][key] + 1 | |||
} | |||
table.insert(switchKeyToTemplates[sw][key], entry) | |||
end | end | ||
end | end | ||
| Строка 160: | Строка 172: | ||
local cfg = switchConfigs[sw] or {} | local cfg = switchConfigs[sw] or {} | ||
for _, key in ipairs(switchKeyOrder[sw]) do | for _, key in ipairs(switchKeyOrder[sw]) do | ||
local | local entries = switchKeyToTemplates[sw][key] or {} | ||
local sources = | local tplCalls = {} | ||
local sources = {} | |||
if #entries > 0 then | |||
table.sort(entries, function(a, b) | |||
if a.priority == b.priority then return a.idx < b.idx end | |||
return a.priority > b.priority | |||
end) | |||
for _, e in ipairs(entries) do | |||
table.insert(tplCalls, e.tpl) | |||
table.insert(sources, e.source) | |||
end | |||
end | |||
if cfg.wrapper then | if cfg.wrapper then | ||
local outStr = cfg.wrapper(key, tplCalls, sources) | local outStr = cfg.wrapper(key, tplCalls, sources) | ||