Module:Infobox
Appearance
Documentation for this module may be created at Module:Infobox/doc
-- Module:Infobox — generic infobox renderer for the Yezur wiki.
-- Emits a floating infobox styled by [[Template:Infobox/styles.css]] via
-- TemplateStyles. Wrapper templates (e.g. Template:Infobox polity) map their
-- own fields onto title / subtitle / image / caption and numbered
-- header / label / data slots, then call {{#invoke:Infobox|render|...}}.
local p = {}
local function clean(s)
if s == nil then return nil end
s = mw.text.trim(s)
if s == '' then return nil end
return s
end
function p.render(frame)
local a = frame.args
local root = mw.html.create('div'):addClass('yz-infobox')
root:tag('div')
:addClass('yz-infobox-title')
:wikitext(clean(a.title) or mw.title.getCurrentTitle().text)
local subtitle = clean(a.subtitle)
if subtitle then
root:tag('div'):addClass('yz-infobox-subtitle'):wikitext(subtitle)
end
local image = clean(a.image)
if image then
local box = root:tag('div'):addClass('yz-infobox-image')
box:wikitext('[[File:' .. image .. '|frameless|280x280px]]')
local caption = clean(a.caption)
if caption then
box:tag('div'):addClass('yz-infobox-caption'):wikitext(caption)
end
end
for i = 1, 100 do
local header = clean(a['header' .. i])
local label = clean(a['label' .. i])
local data = clean(a['data' .. i])
if header then
root:tag('div'):addClass('yz-infobox-header'):wikitext(header)
elseif data then
local row = root:tag('div'):addClass('yz-infobox-row')
if label then
row:tag('div'):addClass('yz-infobox-label'):wikitext(label)
end
row:tag('div'):addClass('yz-infobox-data'):wikitext(data)
end
end
local styles = frame:extensionTag{
name = 'templatestyles',
args = { src = 'Template:Infobox/styles.css' }
}
return styles .. tostring(root)
end
return p