打开/关闭菜单
打开/关闭个人菜单
未登录
如果您进行任何编辑,您的IP地址会公开展示。

Module:Tabber

来自星际公民中文百科
Module documentation[view][edit][history][purge]
This documentation is transcluded from Module:Tabber/doc. Changes can be proposed in the talk page.
Module:Tabber is required by Module:Vehicle.
Module:Tabber is required by Module:VehicleHardpoint.

This module is used by Lua modules to create Tabber layout.


local p = {}

--- Helper function to get Tabber length
--- @param table
--- @return int
local function getTabberLength( t )
	local length = 0
    for k, _ in next, t do
    	if string.find( k, 'label' ) == 1 then
        	length = length + 1
        end
    end
    return length
end

--- Render Tabber
--- @param table data { label{n}, content{n} }
--- @return string wikitext of Tabber
function p.renderTabber( data )
	local tabberContent = {}

	for i = 1, getTabberLength( data ) do
		local label = data[ 'label' .. i ]
		local content = data[ 'content' .. i ]

		if label ~= nil and label ~= '' and content ~= nil and content ~= '' then
			table.insert( tabberContent, table.concat( { '|-|', label, '=', content } ) )
		end
	end
	
	if next( tabberContent ) == nil then
		return ''
	end

	return mw.getCurrentFrame():extensionTag{
        name = 'tabber', content = table.concat( tabberContent )
    }
end

return p
我们为您提供服务需要使用Cookie。使用我们的服务即表示您同意我们使用Cookie。