Module:Template test case: Difference between revisions
Changed my mind, it is not that much similar, after all
(Self-rv: Just found that format=rows can be modified to do that) |
(Changed my mind, it is not that much similar, after all) |
||
Line 175: | Line 175: | ||
columns = 'renderColumns', | columns = 'renderColumns', | ||
rows = 'renderRows', | rows = 'renderRows', | ||
tablerows = 'renderTableRows', | |||
inline = 'renderInline', | inline = 'renderInline', | ||
default = 'renderDefault' | default = 'renderDefault' | ||
Line 445: | Line 446: | ||
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 |