Модуль:Сущность: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 42: | Строка 42: | ||
end | end | ||
local function renderTitleBlock(key, tplCalls, sources, includeHeader) | local function renderTitleBlock(key, tplCalls, sources, includeHeader, frame) | ||
local parts = {} | local parts = {} | ||
if tplCalls and #tplCalls > 0 then | if tplCalls and #tplCalls > 0 then | ||
for i, tpl in ipairs(tplCalls) do | for i, tpl in ipairs(tplCalls) do | ||
local | local add = true | ||
local src = sources and sources[i] | if frame then | ||
local expanded = frame:preprocess(tpl) | |||
add = expanded and trim(expanded) ~= "" | |||
end | |||
if add then | |||
local src = sources and sources[i] | |||
local line = '<div>' .. tpl .. '</div><div class="ts-Сущность-field">' .. makeSourceLink(src) .. '</div>' | |||
table.insert(parts, '<div class="ts-Сущность">' .. line .. '</div>') | |||
end | |||
end | |||
if #parts == 0 then | |||
return "" | |||
end | |||
if includeHeader then | |||
table.insert(parts, 1, "<h2>" .. mw.text.encode(key) .. "</h2>") | |||
end | end | ||
end | end | ||
| Строка 72: | Строка 83: | ||
}, | }, | ||
title = { | title = { | ||
wrapper = function(key, tplCalls, sources) | wrapper = function(key, tplCalls, sources, frame) | ||
return renderTitleBlock(key, tplCalls, sources, true) | return renderTitleBlock(key, tplCalls, sources, true, frame) | ||
end | end | ||
} | } | ||
| Строка 127: | Строка 138: | ||
end | end | ||
if noHeaders and sw == "title" then | if noHeaders and sw == "title" then | ||
local outStr = renderTitleBlock(key, tplCalls, sources, false) | local outStr = renderTitleBlock(key, tplCalls, sources, false, frame) | ||
if outStr and outStr ~= "" then table.insert(outLocal, outStr) end | if outStr and outStr ~= "" then table.insert(outLocal, outStr) end | ||
else | else | ||
if cfg.wrapper then | if cfg.wrapper then | ||
local outStr = cfg.wrapper(key, tplCalls, sources) | local outStr = cfg.wrapper(key, tplCalls, sources, frame) | ||
if outStr and outStr ~= "" then table.insert(outLocal, outStr) end | if outStr and outStr ~= "" then table.insert(outLocal, outStr) end | ||
end | end | ||
| Строка 415: | Строка 426: | ||
end | end | ||
return | return table.concat(out, "\n") | ||
end | end | ||
return p | return p | ||