Jump to content

Module:Stb row: Difference between revisions

From Wiki - Scioly.org
m Adds warning message upon detecting missing param
Removes key list in favor of using keys located in common module
 
Line 1: Line 1:
local p = {}
local p = {}
local getArgs = require("Module:Arguments").getArgs
local getArgs = require("Module:Arguments").getArgs
local columns = require("Module:State tournaments box/common").columns
local valid_keys = {}
for _, column in ipairs(columns) do
table.insert(valid_keys, column.key)
end


function p.main(frame)
function p.main(frame)
local args = getArgs(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")
local row = mw.html.create("tr")
for _, key in ipairs(valid_keys) do
for _, key in ipairs(valid_keys) do

Latest revision as of 00:00, 4 September 2024

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

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

local columns = require("Module:State tournaments box/common").columns
local valid_keys = {}
for _, column in ipairs(columns) do
	table.insert(valid_keys, column.key)	
end

function p.main(frame)
	local args = getArgs(frame)
	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