Module:TournamentGroups

local util_args = require('Module:ArgsUtil') local util_cargo = require('Module:CargoUtil') local util_esports = require('Module:EsportsUtil') local util_text = require('Module:TextUtil')

local m_team = require('Module:Team')

local sep = '%s*,%s*'

local h = {}

function h.printTable(groups) local tbl = mw.html.create('table'):addClass('wikitable') for _, group in ipairs(groups) do		local tr = tbl:tag('tr') tr:tag('th'):wikitext(group) tr:tag('td'):wikitext(table.concat(groups[group],', ')) end return tbl end

local p = {} function p.main(frame) local args = util_args.merge(true) local overviewPage = util_esports.getOverviewPage(args.page) local groups = util_text.split(args.groups, sep) for _, group in ipairs(groups) do		groups[group] = util_args.splitAndMap(args[group], sep, m_team.teamlinkname) end local cargo = {} for i, group in ipairs(groups) do		for _, team in ipairs(groups[group]) do			cargo[#cargo+1] = { _table = 'TournamentGroups', GroupName = group, GroupDisplay = args[group .. '_display'] or group, Team = team, OverviewPage = overviewPage, GroupN = i,			} end end for _, tbl in ipairs(cargo) do		util_cargo.store(tbl, frame) end return h.printTable(groups) end return p