Module:Infobox/tabber

From Nguhcraft Wiki
Revision as of 22:02, 18 December 2024 by Viklo (talk | contribs) (tabber test)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 highestTab = 0
	for k, _ in pairs(parentFrame.args) do
		if type(k) == "number" and k > highestTab then
			highestTab = k
		end
	end
	local tabberStr = ""
	for i = 1, highestTab do
		if parentFrame.args[i] then
			tabberStr = tabberStr .. "|-|" .. (parentFrame.args["name" .. 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