Module:InfoboxAlt

From Railway Operation Simulator Wiki
Jump to navigation Jump to search

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

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	local title = args.title or args.name or ""

	local rows = {}

	for k, v in pairs(args) do
		if k ~= "title" and k ~= "name" and v ~= "" then
			table.insert(rows,
				string.format(
					'<tr><th class="infobox-label">%s</th><td class="infobox-data">%s</td></tr>',
					k,
					v
				)
			)
		end
	end

	table.sort(rows)

	return string.format([[
<table class="infobox">
	<caption class="infobox-title">%s</caption>
	%s
</table>
]], title, table.concat(rows, "\n"))
end

return p