Jump to content

Module:Sandbox/Nux

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Nux (talk | contribs) at 15:26, 15 February 2025 (Created page with 'local p = {} function p.parseEnumParams(frame) local args = frame:getParent().args local result = {} local i = 1 while args["label" .. i] and args["value" .. i] and args["color" .. i] do table.insert(result, { label = mw.ustring.gsub(args["label" .. i] or "", "vv", "$v"), value = tonumber(args["value" .. i]) or 0, color = args["color" .. i] or "" }) i = i + 1 end...'). 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.parseEnumParams(frame)
    local args = frame:getParent().args
    local result = {}
    
    local i = 1
    while args["label" .. i] and args["value" .. i] and args["color" .. i] do
        table.insert(result, {
            label = mw.ustring.gsub(args["label" .. i] or "", "vv", "$v"),
            value = tonumber(args["value" .. i]) or 0,
            color = args["color" .. i] or ""
        })
        i = i + 1
    end
    
    mw.logObject(result)
    return mw.text.jsonEncode(result) -- Returning JSON for debugging purposes
end

return p