Module:Template test case: Difference between revisions

    (don't decode <, etc. as they might sometimes be needed, and we don't want to try and decode & recursively)
    (add an option to make things collapsible, and remove dead code)
    Line 182: Line 182:
    obj.options = templateOptions.other or {}
    obj.options = templateOptions.other or {}


    -- Normalize showcode option
    -- Normalize boolean options
    obj.options.showcode = yesno(obj.options.showcode)
    obj.options.showcode = yesno(obj.options.showcode)
    obj.options.collapsible = yesno(obj.options.collapsible)


    -- Add default template options
    -- Add default template options
    Line 326: Line 327:


    return tostring(root)
    return tostring(root)
    end
    function TestCase:renderCollapsed()
    end
    end


    Line 353: Line 350:
    local format = self.options.format
    local format = self.options.format
    local method = format and methods[format] or 'renderDefault'
    local method = format and methods[format] or 'renderDefault'
    return self[method](self)
    local ret = self[method](self)
    if self.options.collapsible then
    ret = self:makeCollapsible(ret)
    end
    return ret
    end
    end