ATTENTION! The process of updating WiKi to version Eco 10.x has begun. Those wishing to participate can find out more Information on our ECO Contribution Wiki Discord.
From April 26 to May 12, errors may occur in the Wiki, as we will be carrying out a major update to the information processing modules.

Module:ProcessArgs

From Eco - English Wiki

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

local p = {}
function p.norm( origArgs, lowercase )
	if type( origArgs ) ~= 'table' then
		origArgs = mw.getCurrentFrame():getParent().args
	end
	local args = {}
	
	for k, v in pairs( origArgs ) do
		if lowercase and type(k) == "string" then k = k:lower() end
		v = mw.text.trim( tostring( v ) )
		if v ~= '' then
			args[k] = v
		end
	end
	
	return args
end

function p.merge( origArgs, parentArgs, norm )
	if type( origArgs ) ~= 'table' then
		norm = origArgs
		local f = mw.getCurrentFrame()
		origArgs = f.args
		parentArgs = f:getParent().args
	end
	local args = {}
	
	for k, v in pairs( origArgs ) do
		v = mw.text.trim( tostring( v ) )
		if not norm or v ~= '' then
			args[k] = v
		end
	end
	
	for k, v in pairs( parentArgs ) do
		v = mw.text.trim( v )
		if not norm or v ~= '' then
			args[k] = v
		end
	end
	
	return args
end
return p