Module:Infobox/tabber: Difference between revisions

From Nguhcraft Wiki
Jump to navigation Jump to search
(stupid Lua)
No edit summary
Line 5: Line 5:
local tabNums = {}
local tabNums = {}
for k, _ in pairs(parentFrame.args) do
for k, _ in pairs(parentFrame.args) do
if type(k) == "number" and k > highestTab then
if type(k) == "number" then
table.insert(tabNumus, k)
table.insert(tabNums, k)
end
end
end
end

Revision as of 08:42, 19 December 2024

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