Module:Team appearances list

This is an old revision of this page, as edited by Izkala (talk | contribs) at 13:07, 31 May 2015 (Further, any number of positional parameters may be specified; these will be added to the front of the list.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- This module produces a horizontal list of team appearances at a specified
-- sports competition; each item is in the format:
-- [[<team> at the <year> <competition>|<year]]. The module requires the
-- following parameters: begin_year, interval, team and competition. end_year
-- may be optionally defined if the sports competition is now defunct. Further,
-- any number of positional parameters may be specified; these will be added to
-- the front of the list.

local p = {}
local compressSparseArray = require('Module:TableTools').compressSparseArray
local hlist = require('Module:List').horizontal

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame)
	return p._main(args)
end
 
function p._main(args)
	local appearances = compressSparseArray(args)
	for i = args.begin_year, (args.end_year or os.date('%Y')+args.interval), 
			args.interval do
		table.insert(appearances, mw.ustring.format('[[%s at the %s %s|%s]]',
			args.team, i, args.competition, i))
	end
	return hlist(appearances)
end

return p