Module:parameters: Verskil tussen weergawes

Content deleted Content added
No edit summary
Naudefj (Besprekings | bydraes)
Werk by vanaf en:
Lyn 15:
local required = {}
local patterns = {}
local names_with_equal_sign = {}
local list_from_index = nil
Line 59 ⟶ 60:
if string.find(name, "=") then
-- DO NOT SIDE-EFFECT A TABLE WHILE ITERATING OVER IT.
require("Module:debug").track("parameters/name with equals")
-- Some elements may be skipped or processed twice if you do.
params[string.gsub(name, "=", "")] = params[name]
-- Instead, track the changes we want to make to `params`, and
params[name] = nil
-- do them after the iteration over `params` is done.
table.insert(names_with_equal_sign, name)
end
elseif param.default ~= nil then
Line 67 ⟶ 70:
end
end
 
--Process required changes to `params`
for _, name in ipairs(names_with_equal_sign) do
require("Module:debug").track("parameters/name with equals")
params[string.gsub(name, "=", "")] = params[name]
params[name] = nil
end
 
-- Process the arguments
local args_unknown = {}
Line 92 ⟶ 102:
end
end
end
local param = params[name]
-- If a parameter without the trailing index was found, and
-- require_index is set on the param, set the param to nil to treat it
-- as if it isn't recognized.
if not index and param and param.require_index then
param = nil
end
Line 97 ⟶ 116:
-- This makes list parameters like g, g2, g3 put g at index 1.
index = index or 1
local param = params[name]
-- If the argument is not in the list of parameters, trigger an error.