Template:For
(Redirected from Template:For loop)
This template has been protected from editing to prevent vandalism. Please discuss changes on the talk page or request unprotection. |
This documentation is transcluded from Template:For/doc.
Uses Lua: |
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 |
2 3 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 }} |
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199 |
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}} |
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.