require('strict')local p = local infobox_image = require('Module:InfoboxImage').InfoboxImage
function p._main(args)
local root = mw.html.create root = root :tag('table') :addClass('infobox') :addClass('cabinet-members') :addClass(args.float and ('cabinet-members-' .. args.float:lower) or 'cabinet-members-right')
local columns = args.party_column and 4 or 3 mw.log(columns) if args.topcaption then args.topcaption = tostring(mw.html.create('div') :cssText(args.topcaptionstyle) :wikitext(args.topcaption) ) end if args.topimage then root :tag('tr'):tag('td') :attr('colspan', columns) :addClass('cabinet-members-image') :wikitext(infobox_image .. (args.topcaption or )) end if args.above then root :tag('tr'):tag('th') :attr('colspan', columns) :addClass('cabinet-members-above') :wikitext(args.above) end if args.caption then args.caption = tostring(mw.html.create('div') :cssText(args.captionstyle) :wikitext(args.caption) ) end if args.image then root :tag('tr'):tag('td') :attr('colspan', columns) :addClass('cabinet-members-image') :wikitext(infobox_image .. (args.caption or )) end -- Actual table local cabinet = mw.html.create('table') local header = cabinet:tag('tr') header:tag('th') :addClass('cabinet-members-header') :wikitext(args.office_label or 'Office') :attr('scope', 'col') header:tag('th') :wikitext(args.name_label or 'Name') :attr('scope', 'col') if args.party_column then header:tag('th') :wikitext(args.party_label or 'Party') :attr('scope', 'col') end header:tag('th') :wikitext(args.term_label or 'Term') :attr('scope', 'col')
local subRows = local keys = for k, v in pairs(args) do k = tostring(k) local num = k:match('^office(%d+)$') if num and args['name' .. num .. 'a'] then num = tonumber(num) if subRows[num]
local num, l = k:match('^name(%d+)([a-z])$') if num then num = tonumber(num) if subRows[num]
for _, num in ipairs(keys) do local row_table = for _, letter in pairs(subRows[num]) do table.insert(row_table, letter) end table.sort(row_table) for j, letter in pairs(row_table) do local row = mw.html.create('tr') if j
return base_templatestyles .. templatestyles .. tostring(root)end
function main(frame) local args = require('Module:Arguments').getArgs(frame) return p._main(args)end
return p