Template:For/doc: Difference between revisions
More actions
→Reserved name: update: rm |
Fix language-code links to use Wikipedia interwiki prefixes |
||
| (20 intermediate revisions by 8 users not shown) | |||
| Line 1: | Line 1: | ||
[[ | {{for2|the template equivalent to <nowiki>{{</nowiki>[[w:template:for|for]]<nowiki>}}</nowiki> on the English Wikipedia|[[template:for2]]}} | ||
---- | {{Lua|Module:ForLoop}} | ||
< | {{TemplateBox | ||
|1 = 1 | |||
| | |1label-en= separator | ||
| | |1d-en = What to separate entries with | ||
| | |1aliases = <!-- List of aliases, separated by / (a slash) --> | ||
| | |1type = <!-- number, string, string/wiki-user-name, string/wiki-page-name, string/line; unknown --> | ||
| | |1def = <!-- default value for the parameter --> | ||
| | |1stat = suggested | ||
| | |||
| | |2 = call | ||
| | |2label-en= template | ||
|2d-en = The template to call in each iteration | |||
|2aliases = | |||
|2type = wiki-template-name | |||
---- | |2def = void | ||
|2stat = required | |||
|3 = pc1n | |||
|3label-en= constant parameter 1 | |||
|3d-en = The first constant parameter’s name | |||
|3aliases = | |||
|3type = line | |||
|3def = | |||
|3stat = optional | |||
|4 = pc1v | |||
|4label-en= constant value 1 | |||
|4d-en = The first constant parameter’s value | |||
|4aliases = | |||
|4type = | |||
|4def = | |||
|4stat = optional | |||
|5 = pc2n | |||
|5label-en= constant parameter 2 | |||
|5d-en = The second constant parameter’s name | |||
|5aliases = | |||
|5type = line | |||
|5def = | |||
|5stat = optional | |||
|6 = pc2v | |||
|6label-en= constant value 2 | |||
|6d-en = The second constant parameter’s value | |||
|6aliases = | |||
|6type = | |||
|6def = | |||
|6stat = optional | |||
|7 = pc3n | |||
|7label-en= constant parameter 3 | |||
|7d-en = The third constant parameter’s name | |||
|7aliases = | |||
|7type = line | |||
|7def = | |||
|7stat = optional | |||
|8 = pc3v | |||
|8label-en= constant value 3 | |||
|8d-en = The third constant parameter’s value | |||
|8aliases = | |||
|8type = | |||
|8def = | |||
|8stat = optional | |||
|9 = pc4n | |||
|9label-en= constant parameter 4 | |||
|9d-en = The fourth constant parameter’s name | |||
|9aliases = | |||
|9type = line | |||
|9def = | |||
|9stat = optional | |||
|10 = pc4v | |||
|10label-en= constant value 4 | |||
|10d-en = The fourth constant parameter’s value | |||
|10aliases = | |||
|10type = | |||
|10def = | |||
|10stat = optional | |||
|11 = pv | |||
|11label-en= variable parameter | |||
|11d-en = The variable parameter’s name | |||
|11aliases = | |||
|11type = line | |||
|11def = 1 | |||
|11stat = optional | |||
|12 = prefix | |||
|12label-en= variable prefix | |||
|12d-en = Constant prefix of the variable parameter’s value | |||
|12aliases = | |||
|12type = | |||
|12def = | |||
|12stat = optional | |||
|13 = postfix | |||
- | |13label-en= variable postfix | ||
|13d-en = Constant postfix of the variable parameter’s value | |||
|13aliases = | |||
|13type = | |||
|13def = | |||
|13stat = optional | |||
== | |14 = 2 | ||
The | |14label-en= variable parameters | ||
|14d-en = The variable parameters’ values. Each value goes in its own parameter, starting with parameter 2. | |||
|14aliases = 3 / 4 / … | |||
|14type = | |||
|14def = | |||
|14stat = required | |||
== | |name = for | ||
|desc = The template calls a specified template several times, where one parameter takes each of a list of values; in addition to the variable parameter, for up to 4 parameters a fixed value can be specified. | |||
|usage-notes = | |||
| | |namespace = | ||
| | |usergroup = | ||
| | |shorthand = | ||
| | |mustbesubst = | ||
| | |setscats = | ||
| | |placement = | ||
| | |example = | ||
| | |example-value = | ||
| | |relieson = | ||
| | |seealso = | ||
|print = multi | |||
|type = | |||
|i18n-method = - | |||
|i18n-desc = | |||
|i18n-subpage = | |||
|i18n-mediawiki-msg = | |||
|useTemplateData = | |||
}} | }} | ||
== | == Example == | ||
{| class="wikitable" | {| class="wikitable" | ||
!Code | !Code | ||
!Result | !Result | ||
|- | |- | ||
| | |List of all numbers from 100 to 199, separated by commas:<br> | ||
<pre>1{{for | <pre>1{{for|, 1|call=x1 | ||
|00|01|02|03|04|05|06|07|08|09 | |00|01|02|03|04|05|06|07|08|09 | ||
|10|11|12|13|14|15|16|17|18|19 | |10|11|12|13|14|15|16|17|18|19 | ||
| Line 65: | Line 153: | ||
|80|81|82|83|84|85|86|87|88|89 | |80|81|82|83|84|85|86|87|88|89 | ||
|90|91|92|93|94|95|96|97|98|99 | |90|91|92|93|94|95|96|97|98|99 | ||
}}</pre> | }}</pre> | ||
|1{{for | <nowiki> | ||
|1{{for|, 1|call=x1 | |||
|00|01|02|03|04|05|06|07|08|09 | |00|01|02|03|04|05|06|07|08|09 | ||
|10|11|12|13|14|15|16|17|18|19 | |10|11|12|13|14|15|16|17|18|19 | ||
| Line 79: | Line 166: | ||
|80|81|82|83|84|85|86|87|88|89 | |80|81|82|83|84|85|86|87|88|89 | ||
|90|91|92|93|94|95|96|97|98|99 | |90|91|92|93|94|95|96|97|98|99 | ||
}} | }} | ||
</nowiki> | |||
|- | |- | ||
|{{for|call= | |An example used in {{tl|Facts/Major cities}}:<br> | ||
<pre>{{for||pc1n=decade|pc1v={{{2|{{{decade|}}}}}}|call=Facts/placeParts | |||
{{ | |Amsterdam|Bangkok|Barcelona|Beijing|Berlin|Brussels|Buenos Aires|Cairo|Canton|Cape Town|Chicago|Delhi|Dubai|Frankfurt am Main|Geneva|Hong Kong|Istanbul|Jerusalem|Kolkata|Lagos, Nigeria|London|Los Angeles|Madrid|Mexico City|Moscow|Mumbai|Nairobi|New York City|Osaka|Paris|Rio de Janeiro (city)|Rome|São Paulo (city)|San Francisco|Seoul|Shanghai|Singapore|Stockholm|Sydney|Tokyo|Toronto|Washington, D.C.|Wuhan}}</pre> | ||
<nowiki> | |||
|{{for||pc1n=decade|pc1v={{{2|{{{decade|}}}}}}|call=Facts/placeParts | |||
|Amsterdam|Bangkok|Barcelona|Beijing|Berlin|Brussels|Buenos Aires|Cairo|Canton|Cape Town|Chicago|Delhi|Dubai|Frankfurt am Main|Geneva|Hong Kong|Istanbul|Jerusalem|Kolkata|Lagos, Nigeria|London|Los Angeles|Madrid|Mexico City|Moscow|Mumbai|Nairobi|New York City|Osaka|Paris|Rio de Janeiro (city)|Rome|São Paulo (city)|San Francisco|Seoul|Shanghai|Singapore|Stockholm|Sydney|Tokyo|Toronto|Washington, D.C.|Wuhan}} | |||
</nowiki> | |||
|} | |} | ||
Note that the last part of the separator is used as a prefix; the first prefix needs to be put separately.<includeonly> | |||
[[Category:Function templates]]</includeonly> | |||
Latest revision as of 14:22, 15 August 2026
The template calls a specified template several times, where one parameter takes each of a list of values; in addition to the variable parameter, for up to 4 parameters a fixed value can be specified.
Usage
{{for
|1 =
|call =
|pc1n =
|pc1v =
|pc2n =
|pc2v =
|pc3n =
|pc3v =
|pc4n =
|pc4v =
|pv =
|prefix =
|postfix =
|2 =
}}
Template parameters
| Parameter | Description | Default | Status | |
|---|---|---|---|---|
1 | separator | What to separate entries with | empty | suggested |
call | template | The template to call in each iteration | void | required |
pc1n | constant parameter 1 | The first constant parameter’s name | empty | optional |
pc1v | constant value 1 | The first constant parameter’s value | empty | optional |
pc2n | constant parameter 2 | The second constant parameter’s name | empty | optional |
pc2v | constant value 2 | The second constant parameter’s value | empty | optional |
pc3n | constant parameter 3 | The third constant parameter’s name | empty | optional |
pc3v | constant value 3 | The third constant parameter’s value | empty | optional |
pc4n | constant parameter 4 | The fourth constant parameter’s name | empty | optional |
pc4v | constant value 4 | The fourth constant parameter’s value | empty | optional |
pv | variable parameter | The variable parameter’s name | 1 | optional |
prefix | variable prefix | Constant prefix of the variable parameter’s value | empty | optional |
postfix | variable postfix | Constant postfix of the variable parameter’s value | empty | optional |
23 4 … | variable parameters | The variable parameters’ values. Each value goes in its own parameter, starting with parameter 2. | empty | required |
Additional information
The template is intended to be used in the following namespaces: no namespace specified
The template is intended to be used by the following user groups: no user group specified
Localization
This template is not intended to be localized.
Example
| Code | Result |
|---|---|
List of all numbers from 100 to 199, separated by commas:1{{for|, 1|call=x1
|00|01|02|03|04|05|06|07|08|09
|10|11|12|13|14|15|16|17|18|19
|20|21|22|23|24|25|26|27|28|29
|30|31|32|33|34|35|36|37|38|39
|40|41|42|43|44|45|46|47|48|49
|50|51|52|53|54|55|56|57|58|59
|60|61|62|63|64|65|66|67|68|69
|70|71|72|73|74|75|76|77|78|79
|80|81|82|83|84|85|86|87|88|89
|90|91|92|93|94|95|96|97|98|99
}}
|1{{for|, 1|call=x1 |00|01|02|03|04|05|06|07|08|09 |10|11|12|13|14|15|16|17|18|19 |20|21|22|23|24|25|26|27|28|29 |30|31|32|33|34|35|36|37|38|39 |40|41|42|43|44|45|46|47|48|49 |50|51|52|53|54|55|56|57|58|59 |60|61|62|63|64|65|66|67|68|69 |70|71|72|73|74|75|76|77|78|79 |80|81|82|83|84|85|86|87|88|89 |90|91|92|93|94|95|96|97|98|99 }} | |
An example used in {{Facts/Major cities}}:{{for||pc1n=decade|pc1v={{{2|{{{decade|}}}}}}|call=Facts/placeParts
|Amsterdam|Bangkok|Barcelona|Beijing|Berlin|Brussels|Buenos Aires|Cairo|Canton|Cape Town|Chicago|Delhi|Dubai|Frankfurt am Main|Geneva|Hong Kong|Istanbul|Jerusalem|Kolkata|Lagos, Nigeria|London|Los Angeles|Madrid|Mexico City|Moscow|Mumbai|Nairobi|New York City|Osaka|Paris|Rio de Janeiro (city)|Rome|São Paulo (city)|San Francisco|Seoul|Shanghai|Singapore|Stockholm|Sydney|Tokyo|Toronto|Washington, D.C.|Wuhan}}
|{{for||pc1n=decade|pc1v={{{2|{{{decade|}}}}}}|call=Facts/placeParts |Amsterdam|Bangkok|Barcelona|Beijing|Berlin|Brussels|Buenos Aires|Cairo|Canton|Cape Town|Chicago|Delhi|Dubai|Frankfurt am Main|Geneva|Hong Kong|Istanbul|Jerusalem|Kolkata|Lagos, Nigeria|London|Los Angeles|Madrid|Mexico City|Moscow|Mumbai|Nairobi|New York City|Osaka|Paris|Rio de Janeiro (city)|Rome|São Paulo (city)|San Francisco|Seoul|Shanghai|Singapore|Stockholm|Sydney|Tokyo|Toronto|Washington, D.C.|Wuhan}} |
Note that the last part of the separator is used as a prefix; the first prefix needs to be put separately.