<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="es">
	<id>https://www.museo8bits.com/wiki/index.php?action=history&amp;feed=atom&amp;title=M%C3%B3dulo%3AArgumentos%2Fdoc</id>
	<title>Módulo:Argumentos/doc - Historial de revisiones</title>
	<link rel="self" type="application/atom+xml" href="https://www.museo8bits.com/wiki/index.php?action=history&amp;feed=atom&amp;title=M%C3%B3dulo%3AArgumentos%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://www.museo8bits.com/wiki/index.php?title=M%C3%B3dulo:Argumentos/doc&amp;action=history"/>
	<updated>2026-05-14T03:45:50Z</updated>
	<subtitle>Historial de revisiones de esta página en la wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://www.museo8bits.com/wiki/index.php?title=M%C3%B3dulo:Argumentos/doc&amp;diff=7564&amp;oldid=prev</id>
		<title>Museo8bits: Página creada con «Este módulo provee un procesamiento fácil a los argumentos que pasan de &lt;code&gt;#invoke&lt;/code&gt;. Es un metamódulo, pensado para s…»</title>
		<link rel="alternate" type="text/html" href="https://www.museo8bits.com/wiki/index.php?title=M%C3%B3dulo:Argumentos/doc&amp;diff=7564&amp;oldid=prev"/>
		<updated>2021-10-24T12:23:26Z</updated>

		<summary type="html">&lt;p&gt;Página creada con «Este módulo provee un procesamiento fácil a los argumentos que pasan de &amp;lt;code&amp;gt;#invoke&amp;lt;/code&amp;gt;. Es un &lt;a href=&quot;/wiki/index.php?title=Categor%C3%ADa:Wikipedia:Metam%C3%B3dulos_Lua&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Categoría:Wikipedia:Metamódulos Lua (la página no existe)&quot;&gt;metamódulo&lt;/a&gt;, pensado para s…»&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Página nueva&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Este módulo provee un procesamiento fácil a los argumentos que pasan de &amp;lt;code&amp;gt;#invoke&amp;lt;/code&amp;gt;. Es un [[:Categoría:Wikipedia:Metamódulos Lua|metamódulo]], pensado para ser usado por otros módulos, y no debería ser llamado directamente desde &amp;lt;code&amp;gt;#invoke&amp;lt;/code&amp;gt;. Entre sus características se incluyen:&lt;br /&gt;
*Eliminar espacios en blanco al principio y final de los valores (no implementado todavía)&lt;br /&gt;
*Eliminar parámetros vacíos (no implementado todavía)&lt;br /&gt;
*Los argumentos pueden ser pasados por el marco actual y el marco padre a la vez (no implementado todavía)&lt;br /&gt;
*Los argumentos pueden ser pasados por otro módulo Lua o desde la [[depurador|consola de depuración]].&lt;br /&gt;
*La mayoría de las características pueden ser personalizadas.&lt;br /&gt;
&lt;br /&gt;
==Uso básico==&lt;br /&gt;
Para empezar, se debe cargar el módulo. Contiene una función, llamada &amp;lt;code&amp;gt;obtenerArgumentos&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local dameArgs = require(&amp;#039;Módulo:Argumentos&amp;#039;).obtenerArgumentos&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
En el escenario más básico, se puede usar obtenerArgumentos dentro de la función principal (usualmente &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt;).&lt;br /&gt;
La variable &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; es una tabla que contiene los argumentos de #invoke.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local dameArgs = require(&amp;#039;Módulo:Argumentos&amp;#039;).obtenerArgumentos&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(marco)&lt;br /&gt;
	local args = dameArgs(marco)&lt;br /&gt;
	-- El código principal del módulo vas acá&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sin embargo, se recomienda usar una función solo para procesar los argumentos de #invoke. Esto significa que si se llama al módulo desde otro módulo Lua, no es necesario tener un objeto marco disponible, mejorando el rendimiento.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local dameArgs = require(&amp;#039;Módulo:Argumentos&amp;#039;).obtenerArgumentos&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(marco)&lt;br /&gt;
	local args = dameArgs(marco)&lt;br /&gt;
	return p._main(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	-- El código principal del módulo vas acá&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si se quiere múltiples funciones que usen los argumentos, y que también sean accesibles desde #invoke, puede usarse una función envolvente.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local dameArgs = require(&amp;#039;Módulo:Argumentos&amp;#039;).obtenerArgumentos&lt;br /&gt;
&lt;br /&gt;
local function hazFuncInvoke(fn)&lt;br /&gt;
	return function (marco)&lt;br /&gt;
		local args = dameArgs(marco)&lt;br /&gt;
		return p[fn](args)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
p.func1 = hazFuncInvoke(&amp;#039;_func1&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
function p._func1(args)&lt;br /&gt;
	-- El código de la primera función va acá&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.func2 = hazFuncInvoke(&amp;#039;_func2&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
function p._func2(args)&lt;br /&gt;
	-- El código de la segunda función va acá&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Opciones ===&lt;br /&gt;
&lt;br /&gt;
Las siguientes opciones están disponible, y son explicadas en las secciones de abajo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local args = dameArgs(marco, {&lt;br /&gt;
	limpiarEspacios = false,&lt;br /&gt;
	removerVacios   = false,&lt;br /&gt;
	fnValores       = function (clave, valor)&lt;br /&gt;
		-- Código para procesar un argumento&lt;br /&gt;
            end,&lt;br /&gt;
	soloMarco       = true,&lt;br /&gt;
	soloPadre       = true,&lt;br /&gt;
	padrePrimero    = true,&lt;br /&gt;
	envolventes     = {&lt;br /&gt;
		&amp;#039;Plantilla:Una plantilla envolvente&amp;#039;,&lt;br /&gt;
		&amp;#039;Plantilla:Otra plantilla envolvente&amp;#039;&lt;br /&gt;
            },&lt;br /&gt;
	soloLectura     = true,&lt;br /&gt;
	noSobreescribir = true&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Eliminar espacios y vacios ===&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Blank arguments often trip up coders new to converting MediaWiki templates to Lua. In template syntax, blank strings and strings consisting only of whitespace are considered false. However, in Lua, blank strings and strings consisting of whitespace are considered true. This means that if you don&amp;#039;t pay attention to such arguments when you write your Lua modules, you might treat something as true that should actually be treated as false. To avoid this, by default this module removes all blank arguments.&lt;br /&gt;
&lt;br /&gt;
Similarly, whitespace can cause problems when dealing with positional arguments. Although whitespace is trimmed for named arguments coming from #invoke, it is preserved for positional arguments. Most of the time this additional whitespace is not desired, so this module trims it off by default.&lt;br /&gt;
&lt;br /&gt;
However, sometimes you want to use blank arguments as input, and sometimes you want to keep additional whitespace. This can be necessary to convert some templates exactly as they were written. If you want to do this, you can set the &amp;lt;code&amp;gt;trim&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;removeBlanks&amp;lt;/code&amp;gt; arguments to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local args = dameArgs(marco, {&lt;br /&gt;
	limpiarEspacios = false,&lt;br /&gt;
	removerVacios   = false&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Personalización del formato de los argumentos ===&lt;br /&gt;
Algunas veces se desea remover algunos argumentos en blanco pero no otros, o tal vez poner todos los argumentos posicionales en minúscula. Para hacer cosas como estas, se usa la opción &amp;lt;code&amp;gt;fnValores&amp;lt;/code&amp;gt;. La entrada a esta opción debe ser una función que toma dos parámetros, &amp;lt;code&amp;gt;clave&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;, y devuelve un valor sencillo. Este valor es lo que se obtiene cuando acceda al campo &amp;lt;code&amp;gt;clave&amp;lt;/code&amp;gt; en la tabla de &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Ejemplo 1: esta función preserva los espacio en blanco para el primer argumento posicional, pero los elimina de los otros argumentos, y los elimina si quedan vacíos:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local args = dameArgs(marco, {&lt;br /&gt;
	fnValores       = function (clave, valor)&lt;br /&gt;
		if 1 == clave then&lt;br /&gt;
			return valor&lt;br /&gt;
		elseif valor then&lt;br /&gt;
			valor = mw.text.trim(valor) -- Elimina los espacios al comienzo y final del valor&lt;br /&gt;
			if &amp;#039;&amp;#039; ~= valor then         -- Si el valor no quedó vacío&lt;br /&gt;
				return valor        -- Lo devuelve&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return nil                          -- En otros casos, devuelve el valor nulo (es decir, no incluir el valor)&lt;br /&gt;
	end&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ejemplo 2: esta función elimina los argumentos vacíos y convierte todos los argumentos a minúsculas, pero no elimina los espacios del comienzo y final de los parámetros posicionales.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local args = dameArgs(marco, {&lt;br /&gt;
	fnValores       = function (clave, valor)&lt;br /&gt;
		if not valor then&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
		value = mw.ustring.lower(valor)&lt;br /&gt;
		if mw.ustring.find(valor, &amp;#039;%S&amp;#039;) then&lt;br /&gt;
			return valor&lt;br /&gt;
		end&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nota: las funciones de arriba fallarán si se les pasa una entrada que no sea de tipo &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;. Esto puede suceder si se usa la función &amp;lt;code&amp;gt;dametArgs&amp;lt;/code&amp;gt; en la función principal del módulo, y esa función es llamada desde otro módulo Lua. En este caso, es necesario comprobar el tipo de la entrada. Esto no es un problema cuando se usa una función específicamente para obtener los argumentos de #invoke; por ejemplo, cuando se usa una función para ese caso (usualmente &amp;lt;code&amp;gt;p.main&amp;lt;/code&amp;gt;) y otra ser usada por otros módulos (usualmente &amp;lt;code&amp;gt;p._main&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{{cot|Examples 1 and 2 with type checking}}&lt;br /&gt;
Example 1:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local args = getArgs(frame, {&lt;br /&gt;
	valueFunc = function (key, value)&lt;br /&gt;
		if key == 1 then&lt;br /&gt;
			return value&lt;br /&gt;
		elseif type(value) == &amp;#039;string&amp;#039; then&lt;br /&gt;
			value = mw.text.trim(value)&lt;br /&gt;
			if value ~= &amp;#039;&amp;#039; then&lt;br /&gt;
				return value&lt;br /&gt;
			else&lt;br /&gt;
				return nil&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			return value&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local args = getArgs(frame, {&lt;br /&gt;
	valueFunc = function (key, value)&lt;br /&gt;
		if type(value) == &amp;#039;string&amp;#039; then&lt;br /&gt;
			value = mw.ustring.lower(value)&lt;br /&gt;
			if mw.ustring.find(value, &amp;#039;%S&amp;#039;) then&lt;br /&gt;
				return value&lt;br /&gt;
			else&lt;br /&gt;
				return nil&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			return value&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{cob}}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
También, es importante destacar que la función &amp;lt;code&amp;gt;fnValores&amp;lt;/code&amp;gt; es llamada aproximadamente cada vez que se pide un argumento de la tabla &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt;. Por lo tanto, si se quiere mejorar el rendimiento debería verificarse no estar haciando nada ineficiente en ese código.&lt;br /&gt;
&lt;br /&gt;
=== Marcos y marcos padre ===&lt;br /&gt;
Los argumentos de la tabla &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; pueden ser pasados desde el marco actual o del marco padre a la vez. Para enteder qué significa esto, es más fácil dar un ejemplo. Digamos que tenemos un módulo llamado &amp;lt;code&amp;gt;Módulo:EjemploArgs&amp;lt;/code&amp;gt;, qu eimprime los primeros dos parámetros posicionales que se le pasen:&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{{cot|Module:ExampleArgs code}}&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	return p._main(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	local first = args[1] or &amp;#039;&amp;#039;&lt;br /&gt;
	local second = args[2] or &amp;#039;&amp;#039;&lt;br /&gt;
	return first .. &amp;#039; &amp;#039; .. second&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{cob}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Module:ExampleArgs&amp;lt;/code&amp;gt; is then called by &amp;lt;code&amp;gt;Template:ExampleArgs&amp;lt;/code&amp;gt;, which contains the code &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:ExampleArgs|main|firstInvokeArg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. This produces the result &amp;quot;firstInvokeArg&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now if we were to call &amp;lt;code&amp;gt;Template:ExampleArgs&amp;lt;/code&amp;gt;, the following would happen:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 50em; max-width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 60%;&amp;quot; | Code&lt;br /&gt;
! style=&amp;quot;width: 40%;&amp;quot; | Result&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| firstInvokeArg&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs|firstTemplateArg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| firstInvokeArg&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs|firstTemplateArg|secondTemplateArg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| firstInvokeArg secondTemplateArg&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
There are three options you can set to change this behaviour: &amp;lt;code&amp;gt;frameOnly&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;parentOnly&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;parentFirst&amp;lt;/code&amp;gt;. If you set &amp;lt;code&amp;gt;frameOnly&amp;lt;/code&amp;gt; then only arguments passed from the current frame will be accepted; if you set &amp;lt;code&amp;gt;parentOnly&amp;lt;/code&amp;gt; then only arguments passed from the parent frame will be accepted; and if you set &amp;lt;code&amp;gt;parentFirst&amp;lt;/code&amp;gt; then arguments will be passed from both the current and parent frames, but the parent frame will have priority over the current frame. Here are the results in terms of &amp;lt;code&amp;gt;Template:ExampleArgs&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
; frameOnly&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 50em; max-width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 60%;&amp;quot; | Code&lt;br /&gt;
! style=&amp;quot;width: 40%;&amp;quot; | Result&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| firstInvokeArg&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs|firstTemplateArg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| firstInvokeArg&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs|firstTemplateArg|secondTemplateArg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| firstInvokeArg&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
; parentOnly&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 50em; max-width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 60%;&amp;quot; | Code&lt;br /&gt;
! style=&amp;quot;width: 40%;&amp;quot; | Result&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs|firstTemplateArg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| firstTemplateArg&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs|firstTemplateArg|secondTemplateArg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| firstTemplateArg secondTemplateArg&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
; parentFirst&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 50em; max-width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 60%;&amp;quot; | Code&lt;br /&gt;
! style=&amp;quot;width: 40%;&amp;quot; | Result&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| firstInvokeArg&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs|firstTemplateArg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| firstTemplateArg&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{ExampleArgs|firstTemplateArg|secondTemplateArg}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| firstTemplateArg secondTemplateArg&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
# If you set both the &amp;lt;code&amp;gt;frameOnly&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;parentOnly&amp;lt;/code&amp;gt; options, the module won&amp;#039;t fetch any arguments at all from #invoke. This is probably not what you want.&lt;br /&gt;
# In some situations a parent frame may not be available, e.g. if getArgs is passed the parent frame rather than the current frame. In this case, only the frame arguments will be used (unless parentOnly is set, in which case no arguments will be used) and the &amp;lt;code&amp;gt;parentFirst&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;frameOnly&amp;lt;/code&amp;gt; options will have no effect.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
=== Envolventes ===&lt;br /&gt;
La opción &amp;#039;&amp;#039;envolventes&amp;#039;&amp;#039; se usa para indicar un número limitado de plantillas que funcionan como envolentes; es decir, cuyo único propósito es llamar al módulo. Si el módulo detecta que es llamado desde una de estas plantillas, solo comprobará los argumentos del marco padre; de lo contrario solo lo hará con el marco pasado a &amp;lt;code&amp;gt;dameArgs&amp;lt;/code&amp;gt;. Esto le permite al módulo ser llamado tanto desde #invoke como desde una envolvente sin la pérdida de rendimiento asociada a tener que comprobar ambos marcos (el actual y el padre) por cada argumento.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
For example, the only content of [[Template:Side box]] (excluding content in {{tag|noinclude}} tags) is &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:Side box|main}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. There is no point in checking the arguments passed directly to the #invoke statement for this template, as no arguments will ever be specified there. We can avoid checking arguments passed to #invoke by using the &amp;#039;&amp;#039;parentOnly&amp;#039;&amp;#039; option, but if we do this then #invoke will not work from other pages either. If this were the case, the {{para|text|Some text}} in the code &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:Side box|main|text=Some text}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; would be ignored completely, no matter what page it was used from. By using the &amp;lt;code&amp;gt;wrappers&amp;lt;/code&amp;gt; option to specify &amp;#039;Template:Side box&amp;#039; as a wrapper, we can make &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:Side box|main|text=Some text}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; work from most pages, while still not requiring that the module check for arguments on the [[Template:Side box]] page itself.&lt;br /&gt;
&lt;br /&gt;
Wrappers can be specified either as a string, or as an array of strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local args = getArgs(frame, {&lt;br /&gt;
	wrappers = &amp;#039;Template:Wrapper template&amp;#039;&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local args = getArgs(frame, {&lt;br /&gt;
	wrappers = {&lt;br /&gt;
		&amp;#039;Template:Wrapper 1&amp;#039;,&lt;br /&gt;
		&amp;#039;Template:Wrapper 2&amp;#039;,&lt;br /&gt;
		-- Any number of wrapper templates can be added here.&lt;br /&gt;
	}&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
# The module will automatically detect if it is being called from a wrapper template&amp;#039;s /sandbox subpage, so there is no need to specify sandbox pages explicitly.&lt;br /&gt;
# The &amp;#039;&amp;#039;wrappers&amp;#039;&amp;#039; option effectively changes the default of the &amp;#039;&amp;#039;frameOnly&amp;#039;&amp;#039; and &amp;#039;&amp;#039;parentOnly&amp;#039;&amp;#039; options. If, for example, &amp;#039;&amp;#039;parentOnly&amp;#039;&amp;#039; were explicitly set to false with &amp;#039;&amp;#039;wrappers&amp;#039;&amp;#039; set, calls via wrapper templates would result in both frame and parent arguments being loaded, though calls not via wrapper templates would result in only frame arguments being loaded.&lt;br /&gt;
# If the &amp;#039;&amp;#039;wrappers&amp;#039;&amp;#039; option is set and no parent frame is available, the module will always get the arguments from the frame passed to &amp;lt;code&amp;gt;getArgs&amp;lt;/code&amp;gt;.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Escribiendo en la tabla args ===&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Sometimes it can be useful to write new values to the args table. This is possible with the default settings of this module. (However, bear in mind that it is usually better coding style to create a new table with your new values and copy arguments from the args table as needed.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
args.foo = &amp;#039;some value&amp;#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to alter this behaviour with the &amp;lt;code&amp;gt;readOnly&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;noOverwrite&amp;lt;/code&amp;gt; options. If &amp;lt;code&amp;gt;readOnly&amp;lt;/code&amp;gt; is set then it is not possible to write any values to the args table at all. If &amp;lt;code&amp;gt;noOverwrite&amp;lt;/code&amp;gt; is set, then it is possible to add new values to the table, but it is not possible to add a value if it would overwrite any arguments that are passed from #invoke.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Etiquetas ref ===&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
This module uses [[mw:Extension:Scribunto/Lua reference manual#Metatables|metatables]] to fetch arguments from #invoke. This allows access to both the frame arguments and the parent frame arguments without using the &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; function. This can help if your module might be passed {{tag|ref}} tags as input.&lt;br /&gt;
&lt;br /&gt;
As soon as {{tag|ref}} tags are accessed from Lua, they are processed by the MediaWiki software and the reference will appear in the reference list at the bottom of the article. If your module proceeds to omit the reference tag from the output, you will end up with a phantom reference - a reference that appears in the reference list, but no number that links to it. This has been a problem with modules that use &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; to detect whether to use the arguments from the frame or the parent frame, as those modules automatically process every available argument.&lt;br /&gt;
&lt;br /&gt;
This module solves this problem by allowing access to both frame and parent frame arguments, while still only fetching those arguments when it is necessary. The problem will still occur if you use &amp;lt;code&amp;gt;pairs(args)&amp;lt;/code&amp;gt; elsewhere in your module, however.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Limitaciones conocidas ===&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
The use of metatables also has its downsides. Most of the normal Lua table tools won&amp;#039;t work properly on the args table, including the &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; operator, the &amp;lt;code&amp;gt;next()&amp;lt;/code&amp;gt; function, and the functions in the table library. If using these is important for your module, you should use your own argument processing function instead of this module.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{#ifeq:{{SUBPAGENAME}}|sandbox||&lt;br /&gt;
[[Categoría:Metamódulos Lua]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Museo8bits</name></author>
	</entry>
</feed>