Module:Infobox
Appearance
This is the documentation for Module:Infobox, the generic infobox renderer for the Yezur wiki. It is not called directly: wrapper templates such as Template:Infobox polity and Template:Infobox continent map their own named fields onto the slots below and invoke it with {{#invoke:Infobox|render|…}}.
Parameters
| Parameter | Purpose |
|---|---|
title |
The infobox heading. Defaults to the page name when omitted. |
subtitle |
An optional line shown below the title. |
image |
A file name (without the File: prefix), rendered frameless at up to 280 px wide.
|
caption |
An optional caption shown beneath the image. |
headerN |
A full-width section header spanning row N. |
labelN |
The label cell of row N. Shown only alongside a dataN value.
|
dataN |
The value cell of row N. A row is emitted whenever dataN is set; its label is optional.
|
Rows are read in order from N = 1 upward (up to 100); empty values are skipped. Styling is supplied by Template:Infobox/styles.css through TemplateStyles.
-- 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