local p = ;local getArgs = require('Module:Arguments').getArgs;local frame = mw.getCurrentFrame;
local data = ;
local function handleCsvArg(key, value) if (value ~= nil) then local split = mw.text.split(value, ','); if (data[key]
0) then for i,v in ipairs(split) do data[key][i] = frame:expandTemplate end
end endend
local function writeTableHeader(stack) table.insert(stack, '|-' .. '\n'); table.insert(stack, '| colspan="2" style="background: #F2F2F2;" | ' .. '\n'); --table.insert(stack, '| ' .. '\n'); table.insert(stack, '|' .. frame:expandTemplate .. '\n') if (#data['voters'] > 0) then for i,v in ipairs(data.voters) do table.insert(stack, '|scope="col" ' .. frame:expandTemplate .. '\n'); end endend
local function writeTableRow(stack, contestant, first) if (not first) then table.insert(stack, '|-' .. '\n'); end table.insert(stack, '|style="text-align:left;"|' .. contestant .. '\n'); local colCount = 0;
table.insert(stack, '|' .. '\n')
for i,v in ipairs(data.voters) do table.insert(stack, '|' .. '\n'); end end
local function _main(args) handleCsvArg('contestants', args.contestants); if (args.voters ~= nil) then handleCsvArg('voters', args.voters); else data.voters = data.contestants end local stack = ; table.insert(stack, '
-' .. '\n') table.insert(stack, '! rowspan="' .. #data.contestants .. '"' .. frame:expandTemplate .. '\n') local first = true; for i,v in ipairs(data.voters) do writeTableRow(stack, v, first); first = false; end end table.insert(stack, ' |
function p.main(frame) local args = getArgs(frame); return _main(args);end
return p;