Jump to content

Module:Blocks

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Harej (talk | contribs) at 23:30, 28 April 2023 (module for rendering stylized blocks for content). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

function p.main(frame)
    local parent = frame:getParent()
    local pages = {}
    local index = 1

    while parent.args['page' .. index] do
        local pageName = parent.args['page' .. index]
        table.insert(pages, mw.html.create('div')
            :addClass('blocks-block')
            :wikitext('{{' .. pageName .. '}}')
        )
        index = index + 1
    end

    if #pages == 0 then
        return ''
    end

    local mainDiv = mw.html.create('div')
    for _, pageDiv in ipairs(pages) do
        mainDiv:node(pageDiv)
    end

    return tostring(mainDiv)
end

return p