Module:Template test case: Difference between revisions

    (For inline format, contents of "addline" will be displayed next to an additional bullet at the end of the list. Tested in /sandbox, see Module:Template test case/testcases and Template:Test case/testcases#Inline format with _addline.)
    (New format: tablerows (based on columns))
    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