Jump to content

Module:Stb row

From Wiki - Scioly.org
Revision as of 23:35, 3 September 2024 by Nydauron (talk | contribs) (Adds warning message upon detecting missing param)

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

local p = {}
local getArgs = require("Module:Arguments").getArgs

function p.main(frame)
	local args = getArgs(frame)
	-- The order in which the keys are interated over determine the cell order
	-- TODO: Consider moving this to a shared module to prevent inconsistencies
	-- with parent module (Module:State tournament box)
	local valid_keys = {
		"name",
		"type",
		"date",
		"div",
		"format",
	}
	local row = mw.html.create("tr")
	for _, key in ipairs(valid_keys) do
		local cell = mw.html.create("td")
		if args[key] == nil then
			mw.addWarning("Key \"" .. key .. "\" is missing. Is that intentional?")
		else
			cell:wikitext(args[key])
		end
		row:node(cell)
	end
	return row
end

return p