Модуль:Infobox
Для документации этого модуля может быть создана страница Модуль:Infobox/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
local html = mw.html.create('div')
:addClass('decarabia thumb tright')
:css({
['background-color'] = 'transparent',
['border-color'] = 'transparent'
})
local tableEl = html:tag('table')
:css({
width = '320px',
border = '1px solid #c8ccd1',
padding = '5px',
['font-size'] = '10pt'
})
-- Заголовок
if args["имя"] and args["имя"] ~= "" then
tableEl:tag('tr')
:tag('th')
:attr('colspan', '2')
:css({
['font-size'] = '16pt',
['font-family'] = 'Times New Roman',
['text-align'] = 'center'
})
:wikitext(args["имя"])
end
-- Картинка
if args["файл"] and args["файл"] ~= "" then
tableEl:tag('tr')
:tag('td')
:attr('colspan', '2')
:css({
['padding-top'] = '1.2em',
['text-align'] = 'center'
})
:wikitext('[[Файл:' .. args["файл"] .. '|250x250px|center]]')
end
-- Описание
if args["описание"] and args["описание"] ~= "" then
tableEl:tag('tr')
:tag('th')
:attr('colspan', '2')
:css({
['font-size'] = '8pt',
['font-family'] = 'Arial',
['text-align'] = 'center'
})
:wikitext(args["описание"])
end
-- Параметры (1–40)
for i = 1, 40, 2 do
local key = args[tostring(i)]
local val = args[tostring(i + 1)]
if key and key ~= "" then
local row = tableEl:tag('tr')
if val and val ~= "" then
row:tag('td')
:addClass('decarabia-param')
:css('text-align', 'right')
:wikitext(key)
row:tag('td')
:addClass('decarabia-text')
:wikitext(val)
else
row:tag('td')
:attr('colspan', '2')
:css('text-align', 'center')
:wikitext(key)
end
end
end
return tostring(html)
end
return p