模块:InfoBoxBuilder

星臣讨论 | 贡献2017年1月16日 (一) 03:31的版本 (创建页面,内容为“local p = {} local canLink = require('Module:Linker')._canLink; local parse = require('Module:Array').parse; function p.multirow(frame) local values = parse(frame...”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

此模块的文档可以在模块:InfoBoxBuilder/doc创建

local p = {}

local canLink = require('Module:Linker')._canLink;
local parse = require('Module:Array').parse;

function p.multirow(frame)
	local values = parse(frame.args['value'])
	local builder = '|-'
	builder = builder .. '\n!' .. 'rowspan=' .. tostring(#values) .. ' ' .. (frame.args['capmixin'] or '') .. '|' .. frame.args['caption']
	local first = true
	for i,v in pairs(values) do
		if first then
			first = false
		else
			builder = builder .. '\n|-'
		end
		builder = builder .. '\n|' .. (frame.args['valmixin'] or '') .. '|'
		if frame.args['trylink'] ~= nil then
			if canLink(v) then
				builder = builder .. '[[' .. v .. ']]'
				if frame.args['linkcat'] ~= nil then
					builder = builder .. '[[Category:' .. v .. ']]'
				end
			else
				builder = builder .. v;
			end
		else
			builder = builder .. v;
		end
	end
	return builder
end

return p