Модул:parameters/doc

Аз Wiktionary

This is the documentation page for Модул:parameters

Ин модул коркард ва тафтиши далелҳои шаблон таъмин менамояд.

process(args, params, return_unknown)

раванди[вироиш]

Ҷараёни далелҳои бо рўйхати параметрҳои, ва мизи дорои далелҳои коркард бар мегардонад. Параметри args далелҳои ба коркард шавад, муайян мекунад;getParent()args:. ки онҳо далелҳои шумо шояд аз чаҳорчӯбаи ҷустуҷӯи мебошанд. Параметри params рӯйхати параметрҳои эътибор муайян, ва иборат аст аз як суфра аст. Агар як бурҳони дучор мешавад, ки дар ҷадвали параметри, на, бо хатои нишон дода мешавад.

Дар ҷадвали параметрҳо бояд номҳои параметри ҳамчун индекс дошта бошад, ва як мизи (эҳтимолан холӣ) раыами параметр ҳамчун арзиши. Дар ҷадвали холӣ ҳамчун арзиши танҳо гуфта мешавад, ки параметри вуҷуд дорад, вале набояд ягон табобати махсус қабул накунад. барчаспҳои параметри эҳтимолӣ дар поён оварда мешаванд.

Дар ҷадвали мисол параметрҳои (аз Module:translations):

{
	[1] = {required = true, default = "und"},
	[2] = {},
	[3] = {list = true},
	["alt"] = {},
	["sc"] = {},
	["tr"] = {},
}

The return_unknown parameter, if set to true prevents the function from triggering an error when it comes across an argument with a name it doesn't recognise. Instead, the return value is a pair of values: the first is the processed arguments as usual, while the second contains all the unrecognised arguments that were left unprocessed. This allows you to do multi-stage processing, where the entire set of arguments that a template should accept is not known at once. For example, an inflection-table might do some generic processing on some arguments, but then defer processing of the remainder to the function that handles a specific inflectional type.

барчаспҳои параметри[вироиш]

required=true
Дар параметри талаб карда мешавад; хато нишон дода мешавад, агар он аст, набошад. Дар саҳифаи Шаблон ба худ аз ин истисно аст; нест, хато аст, он ҷо нишон дода шудааст.
allow_empty=true
Агар далели арзиши сатри холӣ аст, он аст, ки ба сифр табдил нест, балки нигоҳ мисли-аст.
type=
Муайян кадом навъи арзиши гузаронидани далели ба. Бо нобаёнӣ ин онро ҳамчун сатри матн. Алтернативаҳо мебошанд:
type="boolean"
Арзиши ҳамчун мақодири мантиқиро, муносибат, ё воқеӣ ё чи бардурӯғ. Не арзиши, сатри холӣ, ва сатр "0", "не", "н" ва "козиб" аз дурӯғ муносибат, аз ҳамаи арзишҳои дигар ҳақиқӣ ба шумор меравад.
type="number"
Арзиши аст, ба як қатор табдил, магар ба нул аст.
alias_of=
Муносибат параметри ҳамчун номи кӯтоҳшуда якдигаранд. Вақте ки далелҳои барои ин ишора, ки онҳо ба таври худкор номгузорӣ карда шавад ва захира зери номи номи кӯтоҳшуда аст. Ин имкон медиҳад, барои параметрҳои бо номҳои гуногун алтернативӣ, дар ҳоле ки ҳанӯз ба онҳо табобати, ки агар онҳо танҳо як ном дошт. Он ҳатто мумкин аст, ки барои_номи= кӯтоҳшуда аз ба ном, ки дар параметр худаш нест.
list=
Treat the parameter as a list of values, each having its own parameter name, rather than a single value. The parameters will have a number at the end, except for the first. For example, list=true on a parameter named "head" will include the parameters head=, head2=, head3= and so on. If the parameter name is a number, another number doesn't get appended, but the counting simply continues, e.g. for parameter 3 the sequence is 3=, 4=, 5= etc. List parameters are returned as numbered lists, so for a template that is given the parameters head=a|head2=b|head3=c, the processed value of the parameter head will be {"a", "b", "c"}.
The value for list= can also be a string. This tells the module that parameters other than the first should have a different name, which is useful when the first parameter in a list is a number, but the remainder is named. An example would be for genders: list="g" on a parameter named 1 would have parameters 1=, g2=, g3= etc.
If the number is not located at the end, it can be specified by putting an equal sign "=" at the number position. For example, parameters "f1accel", "f2accel", ... can be captured by using the parameter name "f=accel", as is in Module:headword/templates.
allow_holes=true
This is used in conjunction with list-type parameters. By default, the values are tightly packed in the resulting list. This means that if, for example, an entry specified head=a|head3=c but not head2=, the returned list will be {"a", "c"}, with the values stored as index 1 and 2, not 1 and 3. If it is desirable to keep the numbering intact, for example if the numbers of several list parameters correlate with each other (like those of {{мураккаб}}), then this tag can be specified.
If allow_holes=true is given, there may be nil values in between two real values, which makes many of Lua's table processing functions no longer work, like # or ipairs. To remedy this, the resulting table will contain an additional named value, maxindex, which tells you the highest numeric index that is present in the table. In the example above, the resulting table will now be {"a", nil, "c", maxindex=3}. That way, you can iterate over the values from 1 to maxindex, while skipping nil values in between.
default=
Муайян арзиши пешфарз барои параметри, агар он ғоиб шуд ёки холӣ мебошад. Вақте ки дар бораи параметрҳои рӯйхат истифода бурда мешавад, ин як арзиши пешфарз барои ќисми якум дар рӯйхат танҳо муайян мекунад. Дар хотир доред, ки он имконнопазир аст, ба тавлиди пешфарз, ки вобаста ба арзиши параметрҳои дигар.
Агар дар якҷоягӣ истифода бурда, бо required=true, нобаёнӣ танҳо ба саҳифаи Шаблон ба худи дахл дорад. Ин метавонад истифода шавад барои нишон додани матн намунаи.