Module:Gallery: Difference between revisions

(Created page with "local getArgs = require('Module:Arguments').getArgs local p = {} local root function p.main(frame) local args = getArgs(frame) return p._main(args) end function p._main(args) local filearg = '' local height = '120' local prependarg = '[[File:' local apprendarg = '|frameless|' .. 'x' .. height .. 'px]]' for key,value in pairs(args) do local content = args[key] -- Check if arg is a valid file name if content:match('.[^{}<>]+%.%w+') then content = pr...")
m (1 revision imported: Antares hozzáadva sctoolsról)
 
(No difference)

Latest revision as of 17:04, 1 March 2023

Module documentation[view][edit][history][purge]
This documentation is transcluded from Module:Gallery/doc. Changes can be proposed in the talk page.
Function list
L 5 — p.main
L 10 — p._main

Module:Gallery is a module that implements the {{Gallery}} template. Please see the template page for usage instructions.


local getArgs = require('Module:Arguments').getArgs
local p = {}
local root

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	local filearg = ''
	local height = '120'
	local prependarg = '[[File:'
	local apprendarg = '|frameless|' .. 'x' .. height .. 'px]]'
	
	for key,value in pairs(args) do
			local content = args[key]
			-- Check if arg is a valid file name
			if content:match('.[^{}<>]+%.%w+') then
				content = prependarg .. content .. apprendarg
			end
	    	filearg = filearg .. content
	end
	
	root = mw.html.create('div')
	root
		:addClass('template-gallery')
		:wikitext( filearg )
	
	return tostring(root)
end

return p