Module:SongContestTable
Appearance
![]() | This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. |
![]() | This module depends on the following other modules: |
Usage
[edit]{{#invoke:SongContestTable|function_name}}
local getArgs = require('Module:Arguments').getArgs
local order = require('Module:SongContestData')._order
local rowTemplate = "SongContestTableRow"
local p = {}
function p.main(f)
local args = getArgs(f)
local contest, year, roundInput, wikitable = args[1], args[2], args[3], args['table']
local round, roundNo
if roundInput then
round, roundNo = roundInput:gsub("%d+", ""), tonumber(roundInput:match("%d+"))
end
local sorting
if round then
sorting = round..'_draw'
end
local ordered = {}
if roundNo then
ordered = order({contest, year, sorting, desc=false, excludeAtt=round, excludeVal=roundNo, excludeInvert=true})
else
ordered = order({contest, year, sorting, desc=false})
end
-- build table from template
local result = f:expandTemplate{title=rowTemplate,args={contest, year, roundInput, ['table'] = wikitable, header=1}}
for _,entry in pairs(ordered) do
result = result ..'\n'.. f:expandTemplate{title=rowTemplate,args={contest, year, entry, round, ['table'] = wikitable}}
end
return result..'\n|}'
end
return p