Template:For/doc: Difference between revisions
More actions
use {{TemplateBox}}, move category from main template page |
Fix language-code links to use Wikipedia interwiki prefixes |
||
| (9 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
{{for2|the template equivalent to <nowiki>{{</nowiki>[[ | {{for2|the template equivalent to <nowiki>{{</nowiki>[[w:template:for|for]]<nowiki>}}</nowiki> on the English Wikipedia|[[template:for2]]}} | ||
{{Lua|Module:ForLoop}} | {{Lua|Module:ForLoop}} | ||
{{TemplateBox | {{TemplateBox | ||
| Line 141: | Line 141: | ||
!Result | !Result | ||
|- | |- | ||
| | |List of all numbers from 100 to 199, separated by commas:<br> | ||
<pre>1{{for|, 1|call=x1 | <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 | ||
| Line 154: | Line 154: | ||
|90|91|92|93|94|95|96|97|98|99 | |90|91|92|93|94|95|96|97|98|99 | ||
}}</pre> | }}</pre> | ||
<nowiki> | |||
|1{{for|, 1|call=x1 | |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 | ||
| Line 166: | Line 167: | ||
|90|91|92|93|94|95|96|97|98|99 | |90|91|92|93|94|95|96|97|98|99 | ||
}} | }} | ||
</nowiki> | |||
|- | |||
|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> | 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> | [[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.