Jump to content

Module:Stb row: Difference between revisions

From Wiki - Scioly.org
Initial row implementation that renders HTML
 
m Adds warning message upon detecting missing param
Line 17: Line 17:
for _, key in ipairs(valid_keys) do
for _, key in ipairs(valid_keys) do
local cell = mw.html.create("td")
local cell = mw.html.create("td")
if args[key] ~= nil then
if args[key] == nil then
mw.addWarning("Key \"" .. key .. "\" is missing. Is that intentional?")
else
cell:wikitext(args[key])
cell:wikitext(args[key])
end
end

Revision as of 23:35, 3 September 2024

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