Module:Infobox
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Infobox/doc
local p = {}
function p.infobox(frame)
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Infobox'})
local root = mw.html.create('table')
root
:addClass('infobox')
:css('border', '1px solid #a2a9b1')
:css('background-color', '#f8f9fa')
:css('margin', '0.5em 0 0.5em 1em')
:css('padding', '0.2em')
:css('float', 'right')
:css('clear', 'right')
:css('font-size', '88%')
:css('width', '22em')
-- Above (title)
if args.above then
root:tag('tr')
:tag('th')
:attr('colspan', '2')
:css('text-align', 'center')
:css('font-size', '125%')
:css('font-weight', 'bold')
:css('background-color', '#ccf')
:wikitext(args.above)
end
-- Image
if args.image then
root:tag('tr')
:tag('td')
:attr('colspan', '2')
:css('text-align', 'center')
:wikitext(args.image)
end
-- Caption
if args.caption then
root:tag('tr')
:tag('td')
:attr('colspan', '2')
:css('text-align', 'center')
:wikitext(args.caption)
end
-- Data rows
for i = 1, 30 do
if args['label' .. i] or args['data' .. i] then
local row = root:tag('tr')
if args['label' .. i] then
row:tag('th')
:css('text-align', 'left')
:css('font-weight', 'bold')
:css('vertical-align', 'top')
:wikitext(args['label' .. i])
end
if args['data' .. i] then
row:tag('td')
:css('text-align', 'left')
:css('vertical-align', 'top')
:wikitext(args['data' .. i])
end
end
end
return tostring(root)
end
return p