Location via proxy:
[ UP ]
[Report a bug]
[Manage cookies]
No cookies
No scripts
No ads
No referrer
Show this form
Vai al contenuto
Menu principale
Menu principale
sposta nella barra laterale
nascuend
Navigazion
Plata prinzipala
Portal de comunità
Avenimënc de atualità
Ultimi mudamënc
Plata a caje
Aiut
Crì
Crì
Aspetto
Fé na dunazion
Scrite ite
Culeghete
Strumënc persunei
Fé na dunazion
Contribuisci
Scrite ite
Culeghete
Pagine per utenti anonimi
ulteriori informazioni
Descuscions
Mudaziun de
Modulo:Arguments/man
(seziun)
Jonta rujenedes
Modulo
Descuscion
Ladin
Liej
Muda l wikitest
Storia dl documënt
Strumënc
Strumënc
sposta nella barra laterale
nascuend
Azioni
Liej
Muda l wikitest
Storia dl documënt
Generel
Links che porta tlo
Mudamënc che à da n fé cun chësc
Cëria su n documënt
Plates spezieles
Nfurmazions sun la plata
Ottieni URL breve
Scarica codice QR
Te d'atri proiec
Aspetto
sposta nella barra laterale
nascuend
Mët averda:
Ne as nia fat l'azes. Tüa misciun IP sará da odëi publicamënter sce fejes val'mudaziun. Sce
t'anunziëies
o
fejes na utënza
, tües mudaziuns jará zoruch a to inom utënt adöm cun d'atri vantaji .
Cuntrol anti-spam.
NO
scrì it zech tlo!
=== Custom formatting of arguments === Sometimes you want to remove some blank arguments but not others, or perhaps you might want to put all of the positional arguments in lower case. To do things like this you can use the <code>valueFunc</code> option. The input to this option must be a function that takes two parameters, <code>key</code> and <code>value</code>, and returns a single value. This value is what you will get when you access the field <code>key</code> in the <code>args</code> table. Example 1: this function preserves whitespace for the first positional argument, but trims all other arguments and removes all other blank arguments. <syntaxhighlight lang="lua"> local args = getArgs(frame, { valueFunc = function (key, value) if key == 1 then return value elseif value then value = mw.text.trim(value) if value ~= '' then return value end end return nil end }) </syntaxhighlight> Example 2: this function removes blank arguments and converts all arguments to lower case, but doesn't trim whitespace from positional parameters. <syntaxhighlight lang="lua"> local args = getArgs(frame, { valueFunc = function (key, value) if not value then return nil end value = mw.ustring.lower(value) if mw.ustring.find(value, '%S') then return value end return nil end }) </syntaxhighlight> Note: the above functions will fail if passed input that is not of type <code>string</code> or <code>nil</code>. This might be the case if you use the <code>getArgs</code> function in the main function of your module, and that function is called by another Lua module. In this case, you will need to check the type of your input. This is not a problem if you are using a function specially for arguments from #invoke (i.e. you have <code>p.main</code> and <code>p._main</code> functions, or something similar). {{cot|Examples 1 and 2 with type checking}} Example 1: <syntaxhighlight lang="lua"> local args = getArgs(frame, { valueFunc = function (key, value) if key == 1 then return value elseif type(value) == 'string' then value = mw.text.trim(value) if value ~= '' then return value else return nil end else return value end end }) </syntaxhighlight> Example 2: <syntaxhighlight lang="lua"> local args = getArgs(frame, { valueFunc = function (key, value) if type(value) == 'string' then value = mw.ustring.lower(value) if mw.ustring.find(value, '%S') then return value else return nil end else return value end end }) </syntaxhighlight> {{cob}} Also, please note that the <code>valueFunc</code> function is called more or less every time an argument is requested from the <code>args</code> table, so if you care about performance you should make sure you aren't doing anything inefficient with your code.
Ressumé:
Salvan ti mudazions, azeteies la
condizioni d'uso
, y te ies a una de lascé ti contribuc sota la lizënzes
Creative Commons Attribuzione-Condividi allo stesso modo 4.0
y
GFDL
.Te azeteies ënghe che n culegament ipertestuel o URL sibe assé per l'atribuzion sota la lizënza de Creative Commons.
Scancelea
Aiut per fé mudazions
(gëura n nuef viere)
Anteprima di una pagina con questo template