Documentation for this module may be created at Module:DynamicTable/doc
local getArgs = require('Module:Arguments').getArgs
local DynamicTable = {}
function DynamicTable.main(frame)
local args = getArgs(frame)
local tableContainer = mw.html.create('table'):addClass('wikitable')
if ( args.columns ) then
local split = mw.text.split(args.columns, ',')
local headerRow = mw.html.create('tr')
for i = 1, #split do
local th = mw.html.create('th'):wikitext(mw.text.trim(split[i]))
headerRow:node(th)
end
tableContainer:node(headerRow)
end
tableContainer:node(args.rows)
return tableContainer
end
function DynamicTable.row(frame)
local args = getArgs(frame)
local split = mw.text.split(args[1], ',')
local row = mw.html.create('tr')
for i = 1, #split do
local td = mw.html.create('td'):wikitext(mw.text.trim(split[i]))
if #split == 1 then td:attr('colspan',5) end
row:node(td)
end
return row
end
return DynamicTable