Module:State tournaments box
Jump to navigation
Jump to search
Documentation for this module may be created at Module:State tournaments box/doc
local p = {};
local getArgs = require('Module:Arguments').getArgs
local stringMod = require('Module:String')
function p.main(frame)
local args = getArgs(frame)
table = "<table class='wikitable' id='state-tournaments-box'>"
header = "<tr><th>Name</th><th>Type</th><th>Date</th><th>Division</th><th>Format</th></tr>"
table = table .. header
finalStr = ""
maxRow = 1
for k, v in pairs(args) do
num = tonumber(string.match(k, '%d+'))
if num > maxRow then
maxRow = num
end
end
for i = 1,maxRow do
table = table .. "<tr>"
terms = {"name", "type", "date", "div", "format"}
for f = 1,#terms do
found = false
for k, v in pairs(args) do
if string.find(k, terms[f]) ~= nil and string.match(k, '%d+') == tostring(i) then
table = table .. "<td>" .. v .. "</td>"
found = true
break
end
end
if not found then
table = table .. "<td></td>"
end
end
table = table .. "</tr>"
end
table = table .. "</table>"
return table
end
return p;