Jump to content

Module:Template test case: Difference between revisions

Self-rv: Just found that format=rows can be modified to do that
(New format: tablerows (based on columns))
(Self-rv: Just found that format=rows can be modified to do that)
Line 175: Line 175:
columns = 'renderColumns',
columns = 'renderColumns',
rows = 'renderRows',
rows = 'renderRows',
tablerows = 'renderTableRows',
inline = 'renderInline',
inline = 'renderInline',
default = 'renderDefault'
default = 'renderDefault'
Line 446: Line 445:
end
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')
for i, obj in ipairs(self.templates) do
local dataRow = tableroot:tag('tr')
-- Row header
if self.options.showheader then
dataRow:tag('th')
:attr('scope', 'row')
:css('text-align', 'left')
:wikitext(obj:makeHeader())
dataRow:tag('td')
:css('padding', '0 1em')
:wikitext('→')
end
-- Template output
dataRow:tag('td')
:newline()
:wikitext(self.options.before)
:wikitext(self:getTemplateOutput(obj))
:wikitext(self.options.after)
end
return tostring(root)
return tostring(root)
end
end
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.