Module:Sports results/blank
Appearance
![]() | This module should always be substituted! |
This module is used to sort and add any missing matches to an invocation of Module:Sports results. The only required input is an ordered list of teams, either using the |team_order=
format or the |team1=
, |team2=
, ... format. Any existing match data is preserved and sorted. Any unrecognized parameters are moved to the end of the invocation.
Usage
{{subst:#invoke:Sports results/blank|main
| team_order = AAA, BBB, CCC, ....
}}
or
{{subst:#invoke:Sports results/blank|main
| team1 = AAA
| team2 = BBB
| team3 = CCC
....
}}
Example
{{subst:#invoke:Sports results/blank|main
| team_order = AAA, BBB, CCC
}}
results in
{{#invoke:sports results|main
| source = <!-- source -->
| update = <!-- last updated -->
| team_order = AAA, BBB, CCC
| name_AAA =
| name_BBB =
| name_CCC =
| match_AAA_BBB =
| match_AAA_CCC =
| match_BBB_AAA =
| match_BBB_CCC =
| match_CCC_AAA =
| match_CCC_BBB =
}}
-- This module generates a blank invocation of the head to head module
-- using the values of team1, team2, ...
local p = {}
local function isnotempty(s)
return s and s:match( '^%s*(.-)%s*$' ) ~= ''
end
function p.table(frame)
local args = (frame.args['team1'] ~= nil) and frame.args or frame:getParent().args
-- Count the number of teams
local numteams = 0
while isnotempty(args['team' .. (numteams + 1)]) do
numteams = numteams + 1
end
local res = '{{#invoke:head to head|table\n'
res = res .. '| template_name = <!-- to add v-t-e links -->\n'
res = res .. '| s = <!-- source -->\n'
res = res .. '| u = <!-- last updated -->\n'
res = res .. '\n'
for i=1,numteams do
local ab = args['team' .. i]
res = res .. '| team' .. i .. '= ' .. ab
res = res .. '| name_' .. ab .. '\n'
end
res = res .. '\n'
for i=1,numteams do
local abi = args['team' .. i]
for j=1,numteams do
local abj = args['team' .. j]
if i ~= j then
res = res .. '| match_' .. abi .. '_' .. abj .. ' = '
end
end
end
res = res .. '\n}}'
return res
end
return p