Module:GalleryUtils: Difference between revisions
From Heterodontosaurus Balls
(Created page with "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...") |
m (Protected "Module:GalleryUtils" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
(No difference)
|
Latest revision as of 17:03, 25 July 2024
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) if #parsedArgs < 1 then return "'''Missing arguments for Tabber Gallery'''" end collected = "<tabber>\n" for i=1,#parsedArgs do collected = collected .. createElm(parsedArgs[i]) end return collected .. "\n</tabber>" end return utils