Module:Template test case: Difference between revisions

In the end they could be merged nicely
(renderTableRows: use class and style parameters)
(In the end they could be merged nicely)
Line 175:
columns = 'renderColumns',
rows = 'renderRows',
tablerows = 'renderTableRowsrenderRows',
inline = 'renderInline',
default = 'renderDefault'
Line 434:
 
for _, obj in ipairs(self.templates) do
-- Build the row HTML
if self.options.showheader then
tableroot:tag('tr'):tag('td')
:css('text-align', 'center')
:css('font-weight', 'bold')
:wikitext(obj:makeHeader())
end
tableroot:tag('tr'):tag('td')
:newline()
:wikitext(self:getTemplateOutput(obj))
end
 
return tostring(root)
end
 
function TestCase:renderTableRows()
local root = mw.html.create()
if self.options.showcode then
root
:wikitext(self.templates[1]:getInvocation())
:newline()
end
 
local tableroot = root:tag('table')
tableroot
:addClass(self.options.class)
:cssText(self.options.style)
 
for i, obj in ipairs(self.templates) do
local dataRow = tableroot:tag('tr')
-- Row header
if self.options.showheader then
if self.options.showheaderformat == 'tablerows' then
dataRow:tag('th')
dataRow:attrtag('scope', 'rowth')
:cssattr('text-alignscope', 'leftrow')
:css('text-align', 'left')
:wikitext(obj:makeHeader())
:wikitext(obj:makeHeader())
dataRow:tag('td')
:css('padding', '0 1em')
:wikitext('→')
else
dataRow:tag('thtd')
:css('text-align', 'center')
:css('font-weight', 'bold')
:wikitext(obj:makeHeader())
dataRow = tableroot:tag('tr'):tag('td')
end
end
-- Template output
dataRow:tag('td')
:newline()
:wikitext(self.options.before)
:wikitext(self:getTemplateOutput(obj))
:wikitext(self.options.after)
end
 
return tostring(root)
end
Anonymous user