模块:Gallery:修订间差异

来自决策链云智库
(创建页面,内容为“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 = '|center|frameless|' .. 'x' .. height .. 'px]]' for key,value in pairs(args) do filearg = filearg .. '<td>' .. prependarg .. args[key] .. apprendarg .. '</td>' end root = mw.html.cr…”)
 
无编辑摘要
 
第12行: 第12行:
local height = '120'
local height = '120'
local prependarg = '[[File:'
local prependarg = '[[File:'
local apprendarg = '|center|frameless|' .. 'x' .. height .. 'px]]'
local apprendarg = '|frameless|' .. 'x' .. height .. 'px]]'
for key,value in pairs(args) do
for key,value in pairs(args) do
    filearg = filearg .. '<td>' .. prependarg .. args[key] .. apprendarg .. '</td>'
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
end
root = mw.html.create('table')
root = mw.html.create('div')
root
root
:addClass('gallerytable')
:addClass('template-gallery')
:tag('tr')
:wikitext( filearg )
:wikitext( filearg )
return tostring(root)
return tostring(root)

2024年1月24日 (三) 23:54的最新版本

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