Module:Sandbox/Julio974fr
Appearance
local p = {};
function p.main(frame)
local args = require("Module:Arguments").getArgs(frame)
return p.makeTable(args)
end
function p.makeTable(args)
local root = mw.html.create('table')
-- Table opening
root
:addClass('wikitable sortable')
:tag('caption')
:wikitext(args.caption)
:done()
-- Header
local topcell = nil
topcell = root
:tag('th')
:wikitext(args['image'] or '')-- or parliament_diagram (by default)
:css('text-align', 'center')
:css('background', 'F8F9FA')
-- Table header
row = root:tag('tr')
row -- TODO: Add the cols counter
:tag('th')
:wikitext(args.partytitle or 'Party')
:attr('scope', 'col')
:attr('colpan', '4')
:done()
:tag('th') -- TODO: Have the swings only present if there's a previous election
:wikitext('Votes')
:atr('scope', 'col')
:done()
:tag('th')
:wikitext('%')
:atr('scope', 'col')
:done()
:tag('th')
:wikitext('Seats')
:atr('scope', 'col')
:done()
:tag('th')
:wikitext('+/−')
:atr('scope', 'col')
:done()
-- Each table row
-- TODO: Add the rows (duh)
return root
end
return p