Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:For/doc: Difference between revisions

Template page
Description: link to for2
Fix language-code links to use Wikipedia interwiki prefixes
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{documentation subpage}}
{{for2|the template equivalent to <nowiki>{{</nowiki>[[w:template:for|for]]<nowiki>}}</nowiki> on the English Wikipedia|[[template:for2]]}}
== Description ==
{{Lua|Module:ForLoop}}
{{for2|the template equivalent to <nowiki>{{</nowiki>[[:en:template:for|for]]<nowiki>}}</nowiki> in English Wikipedia|[[template:for2]]}}
{{TemplateBox
The template calls a specified template up to 150 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.
  |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


== Usage ==
  |2        = call
<pre>
  |2label-en= template
{{for
  |2d-en    = The template to call in each iteration
|what to separate the entries with (unnamed parameter; required, but can be the empty string)
  |2aliases =  
|call=template to call
  |2type    = wiki-template-name
|pc1n=name of first parameter with constant value  
  |2def    = void
|pc1v=first constant value
  |2stat    = required
|pc2n=name of second parameter with constant value
 
|pc2v=second constant value
  |3        = pc1n
|pc3n=name of third parameter with constant value
  |3label-en= constant parameter 1
|pc3v=third constant value
  |3d-en    = The first constant parameter’s name
|pc4n=name of fourth parameter with constant value
  |3aliases =
|pc4v=fourth constant value
  |3type    = line
|pv=name of variable parameter
  |3def    =
|prefix=constant first part of the value of pv
  |3stat    = optional
|postfix=constant last part of the value of pv
 
|list of 1 to 150 parameter values (without prefixes and postfixes), with separator "|"
  |4        = pc1v
   (empty parameter values work in the regular way, they are ''not'' ignored like undefined ones)
  |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
  |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    =
}}
}}
</pre>


== Examples ==
== Example ==
{| class="wikitable", border=1
{| class="wikitable"
!Code
!Code
!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
|10|11|12|13|14|15|16|17|18|19
|10|11|12|13|14|15|16|17|18|19
Line 43: 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 55: 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.
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

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
}}

|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.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.