Dota 2 Wiki
(criado)
 
m (Protegeu "Módulo:Arguments" ([Editar=Permitir apenas administradores] (indefinidamente) [Mover=Permitir apenas administradores] (indefinidamente)))
(Sem diferenças)

Revisão das 06h38min de 19 de janeiro de 2018

Documentação para Módulo:Arguments Pular para o código ↴ [ editar | atualizar ]

Documentação para Módulo:Arguments Pular para o código ↴ [ editar | atualizar ]

This module is used to normalise arguments. It removes white space at the beginning and end of arguments and removes empty values.

Usage

This module should generally be used in a separate function, to not prevent usage from other modules.

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

function p.main( frame )
	local args = getArgs()
	return p._main( args )
end

function p._main( args )
	-- The actual function
end

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