This page is protected against editing.

Template:For

From Wikimedia Commons, the free media repository
(Redirected from Template:For loop)
Jump to navigation Jump to search
Protected This template has been protected from editing to prevent vandalism.
Please discuss changes on the talk page or request unprotection.
Template documentationview · edit · history · purge ]
This documentation is transcluded from Template:For/doc.

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

ParameterDescriptionDefaultStatus
1separatorWhat to separate entries withemptysuggested
calltemplateThe template to call in each iterationvoidrequired
pc1nconstant parameter 1The first constant parameter’s nameemptyoptional
pc1vconstant value 1The first constant parameter’s valueemptyoptional
pc2nconstant parameter 2The second constant parameter’s nameemptyoptional
pc2vconstant value 2The second constant parameter’s valueemptyoptional
pc3nconstant parameter 3The third constant parameter’s nameemptyoptional
pc3vconstant value 3The third constant parameter’s valueemptyoptional
pc4nconstant parameter 4The fourth constant parameter’s nameemptyoptional
pc4vconstant value 4The fourth constant parameter’s valueemptyoptional
pvvariable parameterThe variable parameter’s name1optional
prefixvariable prefixConstant prefix of the variable parameter’s valueemptyoptional
postfixvariable postfixConstant postfix of the variable parameter’s valueemptyoptional
2
3
4
variable parametersThe variable parameters’ values. Each value goes in its own parameter, starting with parameter 2.emptyrequired

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.