Content deleted Content added
Alistair3149 (talk | contribs) No edit summary |
Alistair3149 (talk | contribs) No edit summary |
||
Line 27: | Line 27: | ||
table.insert( tabberContent, table.concat( { '|-|', label, '=', content } ) ) |
table.insert( tabberContent, table.concat( { '|-|', label, '=', content } ) ) |
||
end |
end |
||
end |
|||
if tabberContent == {} then |
|||
return '' |
|||
end |
end |
||
Revision as of 07:17, 31 May 2023
This documentation is transcluded from Module:Tabber/doc. Changes can be proposed in the talk page.
Module:Tabber is shared across the Star Citizen Wikis.
This module is shared across the Star Citizen Wikis. Any changes should also be relayed to the GitHub repository.
Function list |
---|
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 pairs(t) do
if k:find( 'label', 1, true ) 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 or label ~= '' ) and ( content ~= nil or content ~= '' ) then
table.insert( tabberContent, table.concat( { '|-|', label, '=', content } ) )
end
end
if tabberContent == {} then
return ''
end
return mw.getCurrentFrame():extensionTag{
name = 'tabber', content = table.concat( tabberContent )
}
end
return p