Jump to content

Module:Flex

From The Petit Planet Wiki
Revision as of 14:01, 12 October 2026 by ReisuDesign (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Module documentation

The documentation for this module is missing. Click here to create it.

local p = {}

function p.main(frame)
    local args = frame:getParent().args
    local items = {}

    -- Collect all numeric positional arguments
    local keys = {}

    for key, _ in pairs(args) do
        local index = tonumber(key)

        if index and index > 0 and index % 1 == 0 then
            table.insert(keys, index)
        end
    end

    -- Keep items in their original positional order
    table.sort(keys)

    for _, index in ipairs(keys) do
        local item = args[index]

        if item and mw.text.trim(item) ~= "" then
            table.insert(items, '<div>' .. item .. '</div>')
        end
    end

    return '<div style="display:flex; column-gap:15px; flex-direction:row; flex-wrap:wrap;">'
        .. table.concat(items)
        .. '</div>'
end

return p