Jump to content

📢 Please make sure to read our Style Guide before editing. For questions, suggestions, or technical issues, please contact Noah.

Module:Infobox

From CrabCraft Wiki
Revision as of 11:37, 21 June 2025 by Noah (talk | contribs) (Created the infobox module)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local p = {}

function p.infobox(frame)
	local args = frame:getParent().args
	local out = {}

	table.insert(out, '{| class="infobox" style="width: 250px;"')

	if args.title then
		table.insert(out, '|-\n! colspan="2" style="font-size:120%; background:#ccc;" | ' .. args.title)
	end
	
	local rows = tonumber(args.rows) or 10

	for i = 1, rows do
		local label = args['label' .. i]
		local data = args['data' .. i]
		if label and data then
			table.insert(out, '|-\n| ' .. label .. ' || ' .. data)
		end
	end

	table.insert(out, '|}')

	return table.concat(out, '\n')
end

return p