Module:MatchList

From TwogPedia
Revision as of 21:57, 4 May 2023 by Couchor (talk | contribs) (Created page with "local getArgs = require('Module:Arguments').getArgs local MatchList = {} local VariablesLua = mw.ext.VariablesLua function MatchList.main(frame) local args = getArgs(frame) VariablesLua.vardefine('matchList', 1) local tableContainer = mw.html.create('div') :addClass('matchList matchInfo') :css('width', args.width or '350px') local title = mw.html.create('div') :addClass('matchList-title') :wikitext(args.title) tableContainer:node(title) local i =...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:MatchList/doc

local getArgs = require('Module:Arguments').getArgs

local MatchList = {}

local VariablesLua = mw.ext.VariablesLua

function MatchList.main(frame)
	local args = getArgs(frame)
	VariablesLua.vardefine('matchList', 1)

	local tableContainer = mw.html.create('div')
		:addClass('matchList matchInfo')
		:css('width', args.width or '350px')
	
	local title = mw.html.create('div')
		:addClass('matchList-title')
		:wikitext(args.title)
		
	tableContainer:node(title)
	
	local i = 1
	
	while (args[i] ~= nil) do
		if string.find(args[i], '<div') ~= nil then
			tableContainer:node(args[i])
		else 
			local playday = mw.html.create('div')
				:addClass('matchList-playday')
				:wikitext(args[i])
			tableContainer:node(playday)
		end
		
		i = i + 1
	end
	-- if tournament, title, promote, relegate ~= nil
	
	-- reset matchList var value 
	VariablesLua.vardefine('matchList', 0)
	return tableContainer
end

return MatchList