Module:Tennis events nav

-- This module implements Template:Infobox tennis tournament event/events. -- [SublimeLinter luacheck-globals:mw]

local p = {} local getBuffer, print = require("Module:OutputBuffer")

local STYLES = { ["singlesdoubles"] = {[=[|- ["1"] = "singlesdoubles", ["men"] = "singlesdoubles", ["mens"] = "singlesdoubles", ["women"] = "singlesdoubles", ["womens"] = "singlesdoubles", ["risingstarsinvitational"] = {[=[|- ["boysgirlssingles"] = {[=[|- ! scope="row" style="font-weight: normal; text-align: right;" | Singles ! scope="row" style="font-weight: normal; text-align: right;" | Doubles ["miamimasters"] = "boysgirlssingles", ["mixeddoubles"] = {[=[|- ! scope="row" style="font-weight: normal; text-align: right;" | Singles ! scope="row" style="font-weight: normal; text-align: right;" | Doubles ["mixed"] = "mixeddoubles", ["grandslam"] = "mixeddoubles", ["mixedandteam"] = {[=[|- ! scope="row" style="font-weight: normal; text-align: right;" | Singles ! scope="row" style="font-weight: normal; text-align: right;" | Doubles ! scope="row" style="font-weight: normal; text-align: right;" | Team ["australianopen"] = {[=[|- ! scope="row" style="font-weight: normal; text-align: right;" | Singles ! scope="row" style="font-weight: normal; text-align: right;" | Doubles ! scope="row" style="font-weight: normal; text-align: right;" | Legends ! scope="row" style="font-weight: normal; text-align: right;" | WC Singles ! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles ]=]},	["frenchopen"] = {[=[|- ! scope="row" style="font-weight: normal; text-align: right;" | Singles ! scope="row" style="font-weight: normal; text-align: right;" | Doubles ! scope="row" style="font-weight: normal; text-align: right;" | Legends ! scope="row" style="font-weight: normal; text-align: right;" | WC Singles ! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles ]=]},	["wimbledonchampionships"] = {[=[|- ! scope="row" style="font-weight: normal; text-align: right;" | Singles ! scope="row" style="font-weight: normal; text-align: right;" | Doubles ! scope="row" style="font-weight: normal; text-align: right;" | Legends ! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles ]=]},	["usopen"] = {[=[|- ! scope="row" style="font-weight: normal; text-align: right;" | Singles ! scope="row" style="font-weight: normal; text-align: right;" | Doubles ! scope="row" style="font-weight: normal; text-align: right;" | Legends ! scope="row" style="font-weight: normal; text-align: right;" | WC Singles ! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles ]=]},	["abnamroworldtennistournament"] = {[=[|- ["doublestwotourneys"] = {[=[|- ! scope="row" style="font-weight: normal; text-align: right;" | Singles ! scope="row" style="font-weight: normal; text-align: right;" | Doubles [""] = {[=[|- ! scope="row" style="font-weight: normal; text-align: right;" | Singles ! scope="row" style="font-weight: normal; text-align: right;" | Doubles
 * Singles
 * Doubles]=]},
 * Singles
 * Doubles
 * colspan="2" | Rising Stars]=]},
 * colspan="2" | Rising Stars]=]},
 * men
 * women
 * boys
 * girls
 * men
 * women]=]},
 * men
 * women
 * men
 * women
 * mixed]=]},
 * men
 * women
 * men
 * women
 * mixed
 * men
 * women]=]},
 * men
 * women
 * boys
 * girls
 * girls
 * men
 * women
 * mixed
 * boys
 * girls
 * men
 * women
 * mixed
 * men
 * women
 * quad
 * men
 * women
 * quad
 * men
 * women
 * boys
 * girls
 * girls
 * men
 * women
 * mixed
 * boys
 * girls
 * −45
 * 45+
 * women
 * men
 * women
 * men
 * women
 * men
 * women
 * boys
 * girls
 * girls
 * men
 * women
 * mixed
 * boys
 * girls
 * men
 * women
 * seniors
 * men
 * women
 * men
 * women
 * boys
 * girls
 * girls
 * men
 * women
 * mixed
 * boys
 * girls
 * men
 * women
 * mixed
 * men
 * women
 * quad
 * men
 * women
 * quad
 * singles
 * doubles
 * wheelchair singles
 * wheelchair doubles]=]},
 * wheelchair doubles]=]},
 * men
 * women
 * men
 * women]=]},
 * men
 * women
 * men
 * women]=]}}

local function pullItem(value, default) value = value and string.lower(string.gsub(value, "%A", "")) if type(STYLES[value]) == "string" then value = STYLES[value] end if STYLES[value] then return STYLES[value][1] else return STYLES[default][1] end end

function p._main(args) local default = "" if args[2] ~= args[3] then default = "doublestwotourneys" end

print('{| style="border-spacing: 0.6em 0; margin: auto; ' ..		 'text-align: center;"') print(string.gsub(pullItem(args.type, default), "{(%a+)}", {prefix = args.prefix or "", year = args[1], tournament = args[2], tournamentd = args[3]})) print("|}") return getBuffer("\n") end

function p.main(frame) local args = require("Module:Arguments").getArgs(frame) return p._main(args) end

return p