Module:MultiTabs

From EarthMC
Jump to navigation Jump to search
local p = {} --p stands for package

function GetTableLng(tbl)
  local getN = 0
  for n in pairs(tbl) do 
    getN = getN + 1 
  end
  return getN
end

function p.create( frame )
	local myTable = frame.args
	for i = #myTable, 1, -1 do
		if myTable[i] == "" then
			table.remove(myTable, i)
		elseif myTable[i] == nil then
        	table.remove(myTable, i)
        end
	end
    local int = GetTableLng(myTable)
    local width = 100/int
	local toReturn = '<div style="display:flex;border-bottom: 1px solid black;text-align:center;vertical-align: middle;line-height: 50px;font-size: 20px;">'
    for i = 1,int,1 
	do 
		toReturn = toReturn..'\n<div style="border: 1px solid black;width:'..width..'%;max-width:300px;height:50px;margin:4px;">'..frame.args[i].."</div>"
    end
	toReturn = toReturn.."</div>"
    return frame:preprocess(toReturn)
end


return p