Hello, you have come here looking for the meaning of the word
Module:User:Rua/parameters. In DICTIOUS you will not only get to know all the dictionary meanings for the word
Module:User:Rua/parameters, but we will also tell you about its etymology, its characteristics and you will know how to say
Module:User:Rua/parameters in singular and plural. Everything you need to know about the word
Module:User:Rua/parameters you have here. The definition of the word
Module:User:Rua/parameters will help you to be more precise and correct when speaking or writing your texts. Knowing the definition of
Module:User:Rua/parameters, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
local export = {}
function export.process(args, params)
-- Process parameters for specific properties
local required = {}
local patterns = {}
for name, param in pairs(params) do
if param.required then
required = true
end
if param.pattern then
patterns = name
end
end
-- Process the arguments
local args_new = {}
for name, val in pairs(args) do
-- Does this argument name match a pattern?
local index = nil
for pattern, pname in pairs(patterns) do
index = mw.ustring.match(name, pattern)
-- It matches, so store the parameter name and the
-- numeric index extracted from the argument name.
if index then
index = tonumber(index)
name = pname
break
end
end
local param = params
-- If the argument is not in the list of parameters, trigger an error.
if not params then
error("The parameter \"" .. name .. "\" does not exist.")
end
-- Empty string is equivalent to nil unless allow_empty is true.
if val == "" and not param.allow_empty then
val = nil
end
-- Convert to proper type if necessary.
if param.type == "boolean" then
val = not (not val or val == "" or val == "0" or val == "no" or val == "n" or val == "false")
elseif param.type == "number" then
val = tonumber(val)
end
-- Can't use "if val" alone, because val may be a boolean false.
if val ~= nil then
-- Mark it as no longer required, as it is present.
required = nil
-- Store the argument value.
if param.pattern then
-- If the parameter has a pattern, then it becomes a list.
if args_new == nil then
args_new = {}
end
args_new = val
else
-- If the parameter is an alias of another, store it as the original,
-- but avoid overwriting it; the original takes precedence.
if not param.alias_of then
args_new = val
elseif args == nil then
args_new = val
end
end
end
end
-- The required table should now be empty.
-- If any entry remains, trigger an error, unless we're in the template namespace.
if mw.title.getCurrentTitle().nsText ~= "Template" then
for name, param in pairs(required) do
error("The parameter \"" .. name .. "\" is required.")
end
end
return args_new
end
return export