Module:Infobox/tabber

From Nguhcraft Wiki
Revision as of 08:42, 19 December 2024 by Viklo (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Infobox/tabber/doc

local p = {}

p.generateTabber = function(frame)
	local parentFrame = frame:getParent()
	local tabNums = {}
	for k, _ in pairs(parentFrame.args) do
		if type(k) == "number" then
			table.insert(tabNums, k)
		end
	end
	table.sort(tabNums)
	local tabberStr = ""
	for _, i in ipairs(tabNums) do
		if parentFrame.args[i] then
			tabberStr = tabberStr .. "|-|" .. (parentFrame.args["label" .. i] or i) .. "=<table style=\"width:100%;border-collapse:collapse\">" .. parentFrame.args[i] .. "</table>"
		end
	end
	if tabberStr == "" then
		return ""
	else
		return "<tr><td colspan=\"2\" style=\"padding:0\">" .. frame:extensionTag("tabber", tabberStr) .. "</td></tr>"
	end
end

return p