Module:Infobox

-- Load necessary modules. require('Module:No globals') local getArgs

-- Helper functions

local function union(t1, t2) local temp = {} for _, v in pairs(t1) do		temp[v] = true end for _, v in pairs(t2) do		temp[v] = true end local ret = {} for k in pairs(temp) do		table.insert(ret, k)	end table.sort(ret) return ret end

-- Box class definition

local Infobox = {} Infobox.__index = Infobox

function Infobox.new(boxType, args, cfg) args = args or {} local obj = {}

-- Set the arguments obj.args = args

return setmetatable(obj, Infobox) end

function Infobox:setParameters local args = self.args

self.title = args.title self.above = args.above self.below = args.below end

function Infobox:export local root = mw.html.create:tag('table') root:addClass('infobox') if(self.title) then local caption = root:tag('caption') caption:addClass('ib-title') caption:wikitext(self.title) end if(self.above) then local trAbove = root:tag('tr') trAbove:attr('colspan', '2') trAbove:addClass('ib-above') trAbove:wikitext(self.above) end if(self.below) then local trBelow = root:tag('tr') trBelow:attr('colspan', '2') trBelow:addClass('ib-below') trBelow:wikitext(self.below) end local templateStyle = mw.getCurrentFrame:extensionTag( 'templatestyles', '', { src = 'Template:Infobox/styles.css' } );

return templateStyle .. tostring(root) end

-- Exports

local p, mt = {}, {}

function p._exportClasses -- For testing. return { Infobox = Infobox } end

function p.main(boxType, args, cfgTables) local box = Infobox.new(boxType, args, cfgTables or mw.loadData('Module:Message box/configuration')) box:setParameters return box:export end

function mt.__index(t, k)	return function (frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end return t.main(k, getArgs(frame, {trim = false, removeBlanks = false})) end end

return setmetatable(p, mt)