Module:Gallery items
Appearance
Implements {{gallery items}}
-- this module implements [[template:gallery items]]
local p = {}
function p.main(frame)
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame)
local width = tonumber(args.width) or 150
local items = {}
for k, v in pairs(args) do
if tonumber(k) and math.fmod(k,2) == 1 then
local i = math.floor(k/2)
items[i] = mw.html.create('li')
:addClass('gallerybox')
:css('width', args['width' .. k] or width)
:tag('div')
:css('width', args['width' .. k] or width)
:css('margin', '0 auto')
:wikitext(args[k])
if items[tonumber(k)+1] then
items[i]
:tag('div')
:addClass('gallerytext')
:css('width', args['width' .. k] or width)
:css('text-align', args['text-align'] or 'center')
:wikitext(items[tonumber(k)+1])
end
end
end
local root = mw.html.create('ul')
:addClass('gallery mw-gallery-nolines nochecker')
:cssText(args.style)
:wikitext(table.concat(items))
return frame:extensionTag{ name = 'gallery' } .. tostring(root)
end
return p