Module:Sandbox/Srolanh/Table
Appearance
-- start
local p = {}
local HtmlBuilder = require('Module:HtmlBuilder')
local root = HtmlBuilder.create()
function p.col2_table(frame)
local colspan = string.lower(frame.args[1])
local border = string.lower(frame.args[2])
if colspan == 'n' then
local header1 = frame.args[3]
local header2 = frame.args[4]
local _table_ = root.tag('table')
if border == 'y' then
_table_.css('border', '1px')
elseif border == 'n' then
_table_.css('border', '0px')
else
return 'Error in parameter 2, must be Y or N'
end
local tr1 = root.tag('tr')
local th1 = root.tag('th')
th1.wikitext(header1)
root = th1.done()
local th2 = root.tag('th')
th2.wikitext(header2)
root = th2.done()
root = tr1.done()
local tr2 = root.tag('tr')
local td1cont = frame.args[5]
local td2cont = frame.args[6]
local td1 = root.tag('td')
td1.wikitext(td1cont)
root = td1.done()
local td2 = root.tag('td')
td2.wikitext(td2cont)
root = td2.done()
root = tr2.done()
root = _table_.done()
elseif colspan == 'y' then
local header = frame.args[3]
local _table_ = root.tag('table')
if border == 'y' then
_table_.css('border', '1px')
elseif border == 'n' then
_table_.css('border', '0px')
else
return 'Error in parameter 2, must be Y or N'
end
local tr1 = root.tag('tr')
local th = root.tag('th')
th.wikitext(header)
th.attr('colspan', '2')
root = th.done()
root = tr1.done()
local tr2 = root.tag('tr')
local td1cont = frame.args[4]
local td2cont = frame.args[5]
local td1 = root.tag('td')
td1.wikitext(td1cont)
root = td1.done()
local td2 = root.tag('td')
td2.wikitext(td2cont)
root = td2.done()
root = tr2.done()
root = _table_.done()
else
return 'Error in parameter 1, must be Y or N'
end
html = tostring(root)
return html
end
return p
-- end