Module:Arguments

From Artifact Wiki
Jump to: navigation, search

Documentation for Module:Arguments [edit] [edit doc]

Use this module in other modules to normalize the template's arguments.

Usage


 1 local getArgs = require( 'Module:Arguments' ).main
 2 local p = {}
 3 
 4 
 5 function p.main( frame )
 6    local args = getArgs()
 7    return p._main( args )
 8 end
 9 
10 
11 function p._main( args )
12    -- Put your code here.
13 end
14 
15 
16 return p

local p = {}

function p.main( old_args )
	if type( old_args ) ~= 'table' then
		old_args = mw.getCurrentFrame():getParent().args
	end

	local args = {}
	for k, v in pairs( old_args ) do
		v = mw.text.trim( tostring( v ) )
		if v ~= '' then
			args[k] = v
		end
	end

	return args
end

return p