Web Analytics

See also ebooksgratis.com: no banners, no cookies, totally FREE.

CLASSICISTRANIERI HOME PAGE - YOUTUBE CHANNEL
Privacy Policy Cookie Policy Terms and Conditions
Template talk:For - 維基百科,自由嘅百科全書

Template talk:For

出自維基百科,自由嘅百科全書

{{for/aux
  |v@=
  |c={{{call}}}
  |pv={{{pv|1}}}
  |prefix={{{prefix|}}}
  |postfix={{{postfix|}}}
  |s={{{sep|}}}
  |pc1={{{pc1|=}}}
  |pc2={{{pc2|=}}}
  |pc3={{{pc3|=}}}
  |pc4={{{pc4|=}}}|
1={{{1|@}}}|2={{{2|@}}}|3={{{3|@}}}|...|150={{{150|@}}}
}}

目錄

[編輯] Documentation

[編輯] Description

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.

[編輯] Usage

{{for
  |call=template to call
  |sep=what to separate the entries with
  |pc1=parameter name=constant value
  |pc2=parameter name=constant value
  |pc3=parameter name=constant value
  |pc4=parameter name=constant value
  |pv=name of variable parameter
  |prefix=constant first part of the value of pv
  |postfix=constant last part of the value of pv
  |list of up to 150 parameter values (without prefixes and postfixes), with separator "|"
}}

[編輯] Examples

Code Result
1{{for
|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
  |call=x1
  |sep=, 1
}}
1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1, 1Template:X1

Note that the last part of the separator is used as a prefix; the first prefix needs to be put separately.


{{for|a|3||c|call=x3|sep=-}} using Template:Tim gives

Template:X3-Template:X3-Template:X3-Template:X3

{{for|p|||3||c|call=t|sep=///}} using Template:Tim gives

Template:T///Template:T///Template:T///Template:T///Template:T///Template:T

{{for|call=short DOW|3|1|5|3|2|sep= / }} using Template:Tim gives

Template:Short DOW / Template:Short DOW / Template:Short DOW / Template:Short DOW / Template:Short DOW

{{for|call=t2|pc1=2=constant|abc|def|ghi}} using Template:Tim gives:

Template:T2Template:T2Template:T2


{{for|call=concat and link to w:en:|sep=, |pc1=John_|pv=2||Lennon|Wayne}} using Template:Timc gives Template:Concat and link to w:en:, Template:Concat and link to w:en:, Template:Concat and link to w:en:

A for-call can give a row or column of choice, e.g. using Template:Tim:

{{for|sep=,|2|3|call=power|prefix=2,}} gives Template:Power,Template:Power

{{for|sep=,|2|3|call=power|prefix=3,}} gives Template:Power,Template:Power

{{for|sep=,|2|3|call=power|postfix=,2}} gives Template:Power,Template:Power

{{for|sep=,|2|3|call=power|postfix=,3}} gives Template:Power,Template:Power



A constant parameter is ignored if it is the same as the (implicitly or explicitly given) variable parameter:

{{for|call=t2|pc1=1=7|pc2=2=5|abc|def|ghi|sep=,}} using Template:Tim gives:

Template:T2,Template:T2,Template:T2


{{for|sep=,|call=x3|1=a=b|2=c=d|3=e}} gives Template:X3,Template:X3,Template:X3


{{#expr:{{for|call=plus square|pv=1|1|2|3|4|5}}}} gives Expression error: Unrecognised punctuation character "[".

Semi-recursive: see Template talk:Foreach/recursion

[編輯] Tables

XML:

<table border=1>
<tr><td>{{for|call=X1|3|1|5|3|2|sep=</td><td>}}</td></tr>
<tr><td>{{for|call=square|3|1|5|3|2|sep=</td><td>}}</td></tr>
</table>

gives

Template:X1 Template:X1 Template:X1 Template:X1 Template:X1
Template:Square Template:Square Template:Square Template:Square Template:Square

HTML:

<table border=1>
<tr><td>{{for|call=X1|3|1|5|3|2|sep=<td>}}
<tr><td>{{for|call=square|3|1|5|3|2|sep=<td>}}
</table>

gives

Template:X1 Template:X1 Template:X1 Template:X1 Template:X1
Template:Square Template:Square Template:Square Template:Square Template:Square

Wikitable:

{| border=1
|-
|{{for|call=X1|3|1|5|3|2|sep={{!!}}}}
|-
|{{for|call=square|3|1|5|3|2|sep={{!!}} }}
|}

gives

Template:X1Template:!!Template:X1Template:!!Template:X1Template:!!Template:X1Template:!!Template:X1
Template:SquareTemplate:!!Template:SquareTemplate:!!Template:SquareTemplate:!!Template:SquareTemplate:!!Template:Square

XML:

<table border=1>
<tr><td>{{for|call=table row example|3|1|5|3|2|sep=</td></tr><tr><td>|pc1=sep1=</td><td>}}
</table>

gives

Template:Table row example
Template:Table row example
Template:Table row example
Template:Table row example
Template:Table row example

HTML:

<table border=1>
<tr><td>{{for|call=table row example|3|1|5|3|2|sep=<tr><td>|pc1=sep1=<td>}}
</table>

gives

Template:Table row example
Template:Table row example
Template:Table row example
Template:Table row example
Template:Table row example

Wikitable:

{| border=1
|-
|{{for|call=table row example|3|1|5|3|2|sep=&nbsp;
{{!}}-
{{!}}|pc1=sep1={{!!}}}}
|}

gives

Template:Table row example 
Template:Table row example 
Template:Table row example 
Template:Table row example 
Template:Table row example

[編輯] Reserved name

A reserved name that cannot be used as list item is "@"; it is ignored, but e.g. @1 is not:

{{for|a|@|@1|b|c|call=x3|sep=-}} gives

Template:X3-Template:X3-Template:X3-Template:X3

[編輯] Related templates

This template is another version of Template:Tim. That version has stopped working due to some software change.

Comparison:

{{{v{{{2 }}}|{{{s }}}{{{{{c}}}|{{{pc1}}}|..|{{{pc4}}}|{{{pv}}}={{{2}}}}}}}}
{{{v{{{2|}}}|{{{s|}}}}}}{{{{{{{{v{{{2|}}}|c}}}|x0}}} |{{{pv}}}={{{2}}}|{{{pc1}}}|..|{{{pc4}}}}}

In the first case (for) the whole output is the default of a parameter named v{{{i }}} that is defined iff the ith parameter is not defined.

In the second case (foreach) the existence is checked twice, once for the separator and once for the main output; if the ith parameter is not defined a dummy template is called.

Both are based on Template:Tiw. Differences are:

  • The Meta versions handle empty parameter values in the regular way, while the en version ignores them.
  • Template For allows "=" in parameter values
  • The difference in the case of conflicting parameter names, mentioned above.

[編輯] See also

Static Wikipedia (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2007 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2006 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu

Static Wikipedia February 2008 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu