Module:Bracket/sandbox
Appearance
![]() | This is the module sandbox page for Module:Bracket (diff). See also the companion subpage for test cases (run). |
![]() | This module depends on the following other modules: |
Wrapper for bracket templates, which can be used in place of the following for reduced Post-expand include size:
- {{2TeamBracket}}
- {{4TeamBracket}}
- {{4TeamBracket-Tennis3}}
- {{4TeamBracket-Tennis35}}
- {{4TeamBracket-Tennis5}}
- {{6TeamBracket}}
- {{7TeamBracket}}
- {{8TeamBracket}}
- {{8TeamBracket-Byes}}
- {{8TeamBracket-Compact-Byes}}
- {{8TeamBracket-Compact-NoSeeds-Byes}}
- {{8TeamBracket-Tennis3}}
- {{8TeamBracket-Tennis5}}
- {{16TeamBracket}}
- {{16TeamBracket-Byes}}
- {{16TeamBracket-Compact-Archery}}
- {{16TeamBracket-Compact-NoSeeds-Byes}}
- {{16TeamBracket-Compact-Tennis3}}
- {{16TeamBracket-Compact-Tennis3-Byes}}
- {{16TeamBracket-Compact-Tennis5}}
- {{16TeamBracket-Compact-Tennis5-Byes}}
- {{16TeamBracket-Tennis3}}
- {{16TeamBracket-Tennis5}}
- {{32TeamBracket}}
- {{32TeamBracket-Byes}}
- {{32TeamBracket-Compact-NoSeeds-Byes}}
- {{32TeamBracket-Compact-Squash5}}
- {{32TeamBracket-Compact-Tennis3}}
- {{32TeamBracket-Tennis3}}
- {{64TeamBracket}}
Usage
{{#invoke:Bracket|template_name}}
Example
{{#invoke:Bracket|16TeamBracket-Compact-Tennis3}}
1st round | 2nd round | Semifinals | Finals | ||||||||||||||||||||||||
Adding new templates
New templates can be added using the following format:
p['TEMPLATE_NAME'] = function (frame)
return p._teamBracket(frame, 'TEMPLATE_NAME', {ALTERNATIVE_PARAMETER_NAMES}, {PARAMETER_DEFAULTS})
end
- TEMPLATE_NAME is the name of the template without "Template:"
- ALTERNATIVE_PARAMETER_NAMES is an array of custom parameters and the standard parameter of Module:Team bracket that they translate to, in the form
CUSTOM_NAME = "STANDARD_NAME"
. For example, a template that uses|RD1-group1 = {{{RD1-group1|{{{group1|}}}}}}
would havegroup1 = "RD1-group1"
. Any parameters that start with a number or contain a dash need to be specified as['CUSTOM_NAME']
, e.g.['RD1-seed01'] = 'RD1-seed1'
. - PARAMETER_DEFAULTS is an array of default parameter values that are used if a parameter is not specified. For example, a template that uses
|RD1 = Quarterfinals
would haveRD1 = "Quarterfinals"
, or a template that uses|team-width = {{{team-width|125}}}
would have['team-width'] = "125"
. Some parameters are automatically determined based on TEMPLATE-NAME unless explicity specified in PARAMETER_DEFAULTS:rounds
is automatically calculated based on the##Team
or##Round
text present in TEMPLATE-NAME. This does not need to be specified.- Templates with
-Tennis##
or-Squash##
in TEMPLATE-NAME will havesets
set to the value of##
. In addition, these templates will have{seeds = "yes", nowrap = "yes"}
set. - Templates with
-Compact
in TEMPLATE-NAME will automatically default tocompact = "yes"
local p = {}
local teamBracket = require('Module:Team bracket').main
function p._teamBracket(frame, template, subs, defs)
args = {}
-- assign defaults
for k, v in pairs(defs) do
args[k] = v
end
-- figure out parameters from template name
teams = mw.ustring.match(template or '', "^(%d*)Team")
if not teams then
teams = mw.ustring.match(template or '', "^(%d*)Round")
elseif teams == "4" then
args.rounds = args.rounds or 2
elseif teams == "8" then
args.rounds = args.rounds or 3
elseif teams == "16" then
args.rounds = args.rounds or 4
end
tennis = mw.ustring.match(template or '', "-Tennis(%d*)")
if tennis then
args.sets = args.sets or tennis
args.seeds = args.seeds or 'yes'
args.nowrap = args.nowrap or 'yes'
end
if string.find(template, "-Compact") then
args.compact = args.compact or 'yes'
end
-- get args and alternative args
for k, v in pairs(frame:getParent().args) do
if subs[k] then
args[subs[k]] = v
else
args[k] = v
end
end
--return template
return require('Module:Team bracket').main(frame:newChild{title = ("Template:" .. template), args = outargs})
end
function p.FourTeamBracket(frame)
return p._teamBracket(frame, '4TeamBracket', {
group1 = "RD1-group1"
}, {
autoseeds = "y",
['RD1-group1'] = ""
})
end
p['4TeamBracket'] = p.FourTeamBracket
function p.FourTeamBracketTennis3(frame)
return p._teamBracket(frame, '4TeamBracket-Tennis3', {}, {
RD2 = "Final",
['team-width'] = 125
})
end
p['4TeamBracket-Tennis3'] = p.FourTeamBracketTennis3
function p.FourTeamBracketTennis5(frame)
return p._teamBracket(frame, '4TeamBracket-Tennis5', {}, {
seeds = '',
RD1 = "Quarterfinals",
RD2 = "Semifinals",
['team-width'] = 125,
['RD1-seed1'] = '',
['RD1-seed2'] = '',
['RD1-seed3'] = '',
['RD1-seed4'] = '',
})
end
p['4TeamBracket-Tennis5'] = p.FourTeamBracketTennis5
function p.FourTeamBracketTennis35(frame)
return p._teamBracket(frame, '4TeamBracket-Tennis35', {}, {
sets = "3/5",
RD1 = "Semifinals",
RD2 = "Final",
['RD1-seed1'] = '',
['RD1-seed2'] = '',
['RD1-seed3'] = '',
['RD1-seed4'] = '',
})
end
p['4TeamBracket-Tennis35'] = p.FourTeamBracketTennis35
function p.EightTeamBracket(frame)
return p._teamBracket(frame, '8TeamBracket', {
group1 = 'RD1-group1',
group2 = 'RD1-group2',
group3 = 'RD2-group1',
['RD1-seed01'] = 'RD1-seed1',
['RD1-seed02'] = 'RD1-seed2',
['RD1-seed03'] = 'RD1-seed3',
['RD1-seed04'] = 'RD1-seed4',
['RD1-seed05'] = 'RD1-seed5',
['RD1-seed06'] = 'RD1-seed6',
['RD1-seed07'] = 'RD1-seed7',
['RD1-seed08'] = 'RD1-seed8',
}, {
['RD1-seed1'] = 1,
['RD1-seed2'] = 8,
['RD1-seed3'] = 4,
['RD1-seed4'] = 5,
['RD1-seed5'] = 2,
['RD1-seed6'] = 7,
['RD1-seed7'] = 3,
['RD1-seed8'] = 6,
})
end
p['8TeamBracket'] = p.EightTeamBracket
function p.EightTeamBracketByes(frame)
return p._teamBracket(frame, '8TeamBracket-Byes', {
group1 = "RD1-group1",
group2 = "RD1-group2",
group3 = "RD2-group1",
Consol = "RD3b"
}, {
seeds = 'yes',
byes = 1,
['team-width'] = '11em',
['score-width'] = '2em',
['RD1-group1'] = '',
['RD1-group2'] = '',
['RD2-group1'] = '',
RD3b = frame:getParent().args['RD3-team3'] and "Third place" or ""
})
end
p['3RoundBracket-Byes'] = p.EightTeamBracketByes
p['8TeamBracket-Byes'] = p.EightTeamBracketByes
function p.EightTeamBracketTennis3(frame)
return p._teamBracket(frame, '8TeamBracket-Tennis3', {}, {
RD1 = 'Quarterfinals',
RD2 = 'Semifinals',
RD3 = 'Final',
['team-width'] = 140,
['RD1-seed1'] = 1,
['RD1-seed2'] = 8,
['RD1-seed3'] = 4,
['RD1-seed4'] = 5,
['RD1-seed5'] = 3,
['RD1-seed6'] = 6,
['RD1-seed7'] = 2,
['RD1-seed8'] = 7,
})
end
p['8TeamBracket-Tennis3'] = p.EightTeamBracketTennis3
function p.EightTeamBracketTennis5(frame)
return p._teamBracket(frame, '8TeamBracket-Tennis5', {}, {
RD1 = 'Quarterfinals',
RD2 = 'Semifinals',
RD3 = 'Final',
})
end
p['8TeamBracket-Tennis5'] = p.EightTeamBracketTennis5
function p.SixteenTeamBracket(frame)
return p._teamBracket(frame, '16TeamBracket', {
subgroup1 = 'RD1-group1',
subgroup2 = 'RD1-group2',
subgroup3 = 'RD1-group3',
subgroup4 = 'RD1-group4',
group1 = 'RD2-group1',
group2 = 'RD2-group2',
group3 = 'RD3-group1',
['RD1-seed01'] = 'RD1-seed1',
['RD1-seed02'] = 'RD1-seed2',
['RD1-seed03'] = 'RD1-seed3',
['RD1-seed04'] = 'RD1-seed4',
['RD1-seed05'] = 'RD1-seed5',
['RD1-seed06'] = 'RD1-seed6',
['RD1-seed07'] = 'RD1-seed7',
['RD1-seed08'] = 'RD1-seed8',
['RD1-seed09'] = 'RD1-seed9',
}, {
['RD1-seed1'] = 1,
['RD1-seed2'] = 16,
['RD1-seed3'] = 8,
['RD1-seed4'] = 9,
['RD1-seed5'] = 5,
['RD1-seed6'] = 12,
['RD1-seed7'] = 4,
['RD1-seed8'] = 13,
['RD1-seed9'] = 6,
['RD1-seed10'] = 11,
['RD1-seed11'] = 3,
['RD1-seed12'] = 14,
['RD1-seed13'] = 7,
['RD1-seed14'] = 10,
['RD1-seed15'] = 2,
['RD1-seed16'] = 15,
})
end
p['16TeamBracket'] = p.SixteenTeamBracket
function p.SixteenTeamBracketTennis3(frame)
return p._teamBracket(frame, '16TeamBracket-Tennis3', {}, {
['team-width'] = 140,
['score-width'] = 25,
RD1 = 'First round',
RD2 = 'Quarterfinals',
RD3 = 'Semifinals',
RD4 = 'Final',
})
end
p['16TeamBracket-Tennis3'] = p.SixteenTeamBracketTennis3
function p.SixteenTeamBracketCompactTennis3(frame)
return p._teamBracket(frame, '16TeamBracket-Compact-Tennis3', {}, {
RD1 = '1st round',
RD2 = '2nd round',
})
end
p['16TeamBracket-Compact-Tennis3'] = p.SixteenTeamBracketCompactTennis3
function p.SixteenTeamBracketCompactTennis3Byes(frame)
return p._teamBracket(frame, '16TeamBracket-Compact-Tennis3-Byes', {}, {
byes = 2,
['seed-width'] = 25,
['team-width'] = 150,
RD1 = '1st round',
RD2 = '2nd round',
RD3 = 'Semifinals',
RD4 = 'Final',
})
end
p['16TeamBracket-Compact-Tennis3-Byes'] = p.SixteenTeamBracketCompactTennis3Byes
p['4RoundBracket-Compact-Tennis3-Byes'] = p.SixteenTeamBracketCompactTennis3Byes
function p.SixteenTeamBracketTennis5(frame)
return p._teamBracket(frame, '16TeamBracket-Tennis5', {}, {
RD1 = 'First round',
RD2 = 'Quarterfinals',
RD3 = 'Semifinals',
RD4 = 'Final',
['seed-width'] = 25,
['team-width'] = 150,
['score-width'] = 12,
})
end
p['16TeamBracket-Tennis5'] = p.SixteenTeamBracketTennis5
function p.SixteenTeamBracketCompactTennis5(frame)
return p._teamBracket(frame, '16TeamBracket-Compact-Tennis5', {}, {
RD1 = 'First round',
RD2 = 'Second round',
RD3 = 'Third round',
RD4 = 'Fourth round',
})
end
p['16TeamBracket-Compact-Tennis5'] = p.SixteenTeamBracketCompactTennis5
function p.SixteenTeamBracketCompactTennis5Byes(frame)
return p._teamBracket(frame, '16TeamBracket-Compact-Tennis5-Byes', {}, {
byes = 1,
RD1 = 'First round',
RD2 = 'Second round',
RD3 = 'Semifinals',
RD4 = 'Final',
})
end
p['16TeamBracket-Compact-Tennis5-Byes'] = p.SixteenTeamBracketCompactTennis5Byes
p['4RoundBracket-Compact-Tennis5-Byes'] = p.SixteenTeamBracketCompactTennis5Byes
function p.SixteenTeamBracketByes(frame)
return p._teamBracket(frame, '16TeamBracket-Byes', {
group1 = "RD1-group1",
group2 = "RD2-group2",
}, {
seeds = 'yes',
byes = 1,
RD1 = 'First round',
RD2 = 'Second round',
RD3 = 'Semifinals',
RD4 = 'Final',
['team-width'] = '11em',
['score-width'] = '2em',
['RD1-group1'] = '',
['RD2-group2'] = '',
})
end
p['4RoundBracket-Byes'] = p.SixteenTeamBracketByes
p['16TeamBracket-Byes'] = p.SixteenTeamBracketByes
return p