มอดูล:Infobox
เอกสารการใช้งานสำหรับมอดูลนี้อาจสร้างขึ้นที่ มอดูล:Infobox/doc
local p = {}
local function esc(v) return v or '' end
function p.infoboxTemplate(frame)
local a = frame.args or frame or frame
local root = mw.html.create('table'):addClass('infobox')
local title = a['honorific-prefix'] or ''
if a.name and a.name ~= '' then title = title .. a.name end
if a['honorific-suffix'] and a['honorific-suffix'] ~= '' then title = title .. ' ' .. a['honorific-suffix'] end
if title ~= '' then root:tag('caption'):addClass('infobox-title'):wikitext(title):done() end
if a.image and a.image ~= '' then
local row=root:tag('tr'); row:tag('td'):attr('colspan','2'):css('text-align','center'):wikitext('[[ไฟล์:'..a.image..'|กลาง|'..(a.image_size or a.imagesize or '220px')..']]'):done(); row:done()
end
if a.caption and a.caption ~= '' then local row=root:tag('tr'); row:tag('td'):attr('colspan','2'):css('text-align','center'):wikitext(a.caption):done(); row:done() end
local keys={'order','monarch','term_start','term_end','predecessor','successor','birth_date','birth_place','party','spouse','alma_mater','religion'}
for _,k in ipairs(keys) do if a[k] and a[k] ~= '' then local row=root:tag('tr'); row:tag('th'):wikitext(k):done(); row:tag('td'):wikitext(a[k]):done(); row:done() end end
for i=1,20 do local office=a['office'..i]; if office and office ~= '' then local row=root:tag('tr'); row:tag('th'):wikitext(office):done(); row:tag('td'):wikitext((a['term_start'..i] or '') .. (a['term_end'..i] and '<br>'..a['term_end'..i] or '')):done(); row:done() end end
return tostring(root)
end
p.infobox = p.infoboxTemplate
return p