Module:Template test case: Difference between revisions

    (For inline format, allow replacing default * prefix with contents of "prefix" parameter (e.g. prefix=# or prefix=:). Tested in /sandbox. Examples in /testcases, Template:Test case/testcases, Template:Collapsible test case/testcases, Template:Test case nowiki/testcases, and Template:Nowiki template demo/testcases.)
    (For a collapsible test case, add option to display the template code in the title. No changes in output unless titlecode=yes. Examples in /testcases, Template:Collapsible test case/testcases, Template:Test case/testcases, Template:Test case nowiki/testcases, and Template:Nowiki template demo/testcases.)
    Line 144: Line 144:
    if format == 'code' then
    if format == 'code' then
    invocation = '<code>' .. mw.text.nowiki(invocation) .. '</code>'
    invocation = '<code>' .. mw.text.nowiki(invocation) .. '</code>'
    elseif format == 'kbd' then
    invocation = '<kbd>' .. mw.text.nowiki(invocation) .. '</kbd>'
    elseif format == 'plain' then
    elseif format == 'plain' then
    invocation = mw.text.nowiki(invocation)
    invocation = mw.text.nowiki(invocation)
    Line 334: Line 336:


    function TestCase:makeCollapsible(s)
    function TestCase:makeCollapsible(s)
    local title = self.options.title or self.templates[1]:makeHeader()
    if self.options.titlecode then
    title = self.templates[1]:getInvocation('kbd')
    end
    local isEqual = self:templateOutputIsEqual()
    local isEqual = self:templateOutputIsEqual()
    local root = mw.html.create('table')
    local root = mw.html.create('table')
    Line 345: Line 351:
    :tag('th')
    :tag('th')
    :css('background-color', isEqual and 'lightgreen' or 'yellow')
    :css('background-color', isEqual and 'lightgreen' or 'yellow')
    :wikitext(self.options.title or self.templates[1]:makeHeader())
    :wikitext(title)
    :done()
    :done()
    :done()
    :done()