Module:Infobox

local p = {} local color = require('Module:Color')._main local getArgs = require('Module:Arguments').getArgs local default = { ['title-textcolor'] = 'white', ['title-bgcolor'] = color({'wiki1'}), ['heading-textcolor'] = 'black', ['heading-bgcolor'] = '#EADCDA', ['image-size'] = '256px', }

function p.main(frame) local args = getArgs(frame, {   wrappers = { 'Template:Infobox' },    trim = false  }) return p._main(args) end

function p._main(args) local infobox = mw.html.create('table') :addClass('infobox') :newline -- Add the infobox title. :tag('tr') :tag('th') :attr('colspan', 2) :css('background', args['title-bgcolor'] or default['title-bgcolor']) :css('text-align', 'center') :css('color', args['title-textcolor'] or default['title-textcolor']) :css('font-weight', 'bold') :wikitext(args['title']) :done :done :newline

if args['image'] then infobox :tag('tr') :tag('td') :attr('colspan', 2) :wikitext(string.format('', args['image'], args['image-size'] or default['image-size'])) :done :done :newline end

local i = 1 while args['trait' .. i] do   -- Insert headings if necessary. if args['heading' .. i] then infobox :tag('tr') :tag('td') :attr('colspan', 2) :css('background', args['heading-bgcolor'] or default['heading-bgcolor']) :css('text-align', 'center') :css('color', args['heading-textcolor'] or default['heading-textcolor']) :css('font-weight', 'bold') :wikitext(args['heading' .. i]) :done :done :newline end

if mw.text.trim(args["trait" .. i]) == 'fullwidth' and args['value' .. i] then infobox :tag('tr') :tag('td') :attr('colspan', 2) :cssText(args['stylevalue' .. i] or 'text-align: center;') :wikitext(args['value' .. i]) :done :done :newline elseif args['value' .. i] then infobox :tag('tr') :tag('th') :css('text-align', 'center') :wikitext(args['trait' .. i] .. ':') :done :tag('td') :wikitext(args['value' .. i]) :done :done :newline end i = i + 1 end

return infobox end

return p