Module:Essay sidebar

From ProleWiki, the proletarian encyclopedia
Revision as of 09:30, 6 October 2023 by CriticalResist (talk | contribs) (test)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
-- This module implements collapsing a div for the "Last Updated" section.

local p = {}

function p.collapse(frame)
    local content = frame.args[1] or ''
    local isExpanded = frame.args.expanded == 'yes'

    local collapseClass = isExpanded and '' or 'mw-collapsed'

    local result = mw.html.create('div')
    result:addClass('lastupdate-container')
    result
        :wikitext('\'\'\'<span class="collapse-icon">▼</span> Last Updated\'\'\'')
        :tag('div')
        :addClass('collapsible-content ' .. collapseClass)
        :wikitext(content)

    return tostring(result)
end

return p