Jump to content

Module:Gallery items

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Frietjes (talk | contribs) at 18:17, 19 December 2018 (Created page with '-- this module implements template:gallery items local p = {} function p.main(frame) local getArgs = require('Module:Arguments').getArgs local args = getA...'). 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)

-- 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) then
    		items[tonumber(k)] = mw.html.create('li')
    			:addClass('gallerybox')
    			:css('width', args['width' .. k] or width)
    			:wikitext(args[k])
    	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