Модуль:parameters/doc
This is the documentation page for Модуль:parameters
Бул модулда шаблон далилдерди кайра иштетүү жана текшерүү менен камсыз кылат.
тартиби түзөтүү
process(args, params, return_unknown)
Параметрлер боюнча бир тизме менен далилдерди кайра иштетип, кайра иштетилген далилдерди камтыган үстөл кайтарат. args параметр иштелип аргументтерин аныктайт; Алар сен алкагында тартып алуу мүмкүн аргументтер бар: frame:getParent().args
. Грекия
параметр жарактуу көрсөткүчтөрдүн тизмесин аныктайт, ошондой эле стол турат. талаш параметр үстөлгө эмес экенин туш болсо, анда ката көрүнүп турат.
параметрлер стол индекстерин катары параметр аттары болушу керек, жана баалуулук катары параметр тегдеринин (балким, бош) стол. баалуулук катары бош стол параметри бар гана айтылат, бирок ал кандайдыр бир өзгөчө мамиле керек. Мүмкүн параметр теги төмөндө келтирилген.
Мисал параметрлери стол (from Module:котормолор):
{
[1] = {required = true, default = "und"},
[2] = {},
[3] = {list = true},
["alt"] = {},
["sc"] = {},
["tr"] = {},
}
аны тааныган_жок
, ысым менен чатакташа аркылуу келгенде кайра белгисиз параметр, чыныгы коюлган болсо, ката ишке кирүүдө чейин милдетин жол бербейт. Анын ордуна, кайра наркы баалуулуктардын бир жуп болуп саналат: экинчи иштетилбеген калган бардык таанылбаган далилдерди камтыйт, ал эми биринчи, адаттагыдай эле кайра иштетилген далилдер болуп саналат. Эгер Сиз шаблон кабыл алууга тийиш болгон далилдерди бүтүндөй комплекси бир белгилүү эмес, көп баскычтуу иштетүү, кыла берет. Мисалы, бир баян стол кээ бир жүйөлөрү боюнча кээ бир жалпы иштеп, бирок андан кийин белгилүү бир грамматика түрүн туткалары иштеп калган иштетүүнү кое турууга мүмкүн.
Параметр теги түзөтүү
required=true
- The parameter is required; an error is shown if it is not present. The template's page itself is an exception; no error is shown there.
allow_empty=true
- If the argument is an empty string value, it is not converted to
nil
, but kept as-is. type=
- Specifies what value type to convert the argument into. The default is to leave it as a text string. Alternatives are:
type="boolean"
- The value is treated as a boolean value, either true or false. No value, the empty string, and the strings "0", "no", "n" and "false" are treated as false, all other values are considered true.
type="number"
- The value is converted into a number, unless it is nil.
alias_of=
- Treat the parameter as an alias of another. When arguments are specified for this parameter, they will automatically be renamed and stored under the alias name. This allows for parameters with multiple alternative names, while still treating them as if they had only one name. It is even possible for the
alias_of=
to have a name that is not a parameter itself. 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 parametershead=
,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 is3=
,4=
,5=
etc. List parameters are returned as numbered lists, so for a template that is given the parametershead=a|head2=b|head3=c
, the processed value of the parameterhead
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 parameters1=
,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 nothead2=
, 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{{compound}}
), 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#
oripairs
. 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 tomaxindex
, while skipping nil values in between. default=
- Specifies a default value for the parameter, if it is absent or empty. When used on list parameters, this specifies a default value for the first item in the list only. Note that it is not possible to generate a default that depends on the value of other parameters.
- If used together with
required=true
, the default applies only to the template's page itself. This can be used to show an example text.