Content deleted Content added
f |
Automate greying out of absences |
||
Line 3:
-- [[<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 either the
-- defunct.
-- each of which must be a year (or year range) in which the team was absent
-- from the competition.
local p = {}
local compressSparseArray = require('Module:TableTools').compressSparseArray
local hlist = require('Module:List').horizontal
local valueUnion = require('Module:Set').valueUnion
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {parentOnly
return p._main(args)
end
function p._main(args)
local appearances =
local absences = {}
for _, v in pairs(compressSparseArray(args)) do
absences[mw.ustring.sub(v, 1, 4)] = mw.getCurrentFrame():expandTemplate{
title='Gray', args={v}}
end
for i = args.begin_year, (args.end_year or os.date('%Y')+args.interval),
args.interval do
if absences[tostring(i)] then
table.insert(appearances, mw.ustring.format('[[%s at the %s %s|%s]]',▼
table.insert(appearances, absences[tostring(i)])
args.team, i, args.competition, i))▼
absences[tostring(i)] = nil
else
▲ '[[%s at the %s %s|%s]]', args.team, i, args.competition, i))
end
end
return hlist(valueUnion(absences, appearances))
end
|