×
Create a new article
Write your page title here:
We currently have 2,427 articles on Polcompball Wiki. Type your article name above or click on one of the titles below and start writing!



Polcompball Wiki

Documentation for this module may be created at Module:GalleryUtils/doc

local utils = {}

local function parseArgs(args)
    parsedArgs = {}
    i = 1
    while args["img"..i] ~= nil do
        local currentTitle = args["title"..i]
        if currentTitle == nil then
            currentTitle = args["img"..i]
        end
        local image = {
            img = args["img"..i],
            caption = args["caption"..i],
            title = currentTitle,
        }
        parsedArgs[i] = image
        i = i + 1
    end
    return parsedArgs
end

local function createElm(elm)
    local elmText = "|-|" .. elm["title"] .. "="
    elmText = elmText .. '<div class="img-wrapper">[[File:' .. elm["img"] .. ']]'
    if elm["caption"] ~= nil then
        elmText = elmText .. '<div class="img-caption">' .. elm["caption"] .. '</div>'
    end
    return elmText .. '</div>\n'
end

function utils.tabberGallery(frame)
    parsedArgs = parseArgs(frame:getParent().args)
    collected = "<tabber>\n"
    for i=1,#parsedArgs do
        collected = collected .. createElm(parsedArgs[i])
    end
    return collected .. "\n</tabber>"
end

return utils