Module:Infobox/tabber: Difference between revisions

From Nguhcraft Wiki
Jump to navigation Jump to search
(tabber test)
 
No edit summary
Line 3: Line 3:
p.generateTabber = function(frame)
p.generateTabber = function(frame)
local parentFrame = frame:getParent()
local parentFrame = frame:getParent()
local highestTab = 0
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" and k > highestTab then
highestTab = k
table.insert(tabNumus, k)
end
end
end
end
tabNums.sort()
local tabberStr = ""
local tabberStr = ""
for i = 1, highestTab do
for _, i in ipairs(tabNums) do
if parentFrame.args[i] then
if parentFrame.args[i] then
tabberStr = tabberStr .. "|-|" .. (parentFrame.args["name" .. i] or i) .. "=<table style=\"width:100%;border-collapse:collapse\">" .. parentFrame.args[i] .. "</table>"
tabberStr = tabberStr .. "|-|" .. (parentFrame.args["label" .. i] or i) .. "=<table style=\"width:100%;border-collapse:collapse\">" .. parentFrame.args[i] .. "</table>"
end
end
end
end

Revision as of 08:40, 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" and k > highestTab then
			table.insert(tabNumus, k)
		end
	end
	tabNums.sort()
	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