Template:For/doc

From Team Fortress Wiki
< Template:For
Revision as of 01:06, 5 September 2023 by Oap (talk | contribs) (Update examples)
Jump to: navigation, search

Description

This template's source code was taken from here: https://meta.wikimedia.org/wiki/Template:For

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

(Note the change for the constant values.)

{{for
  |call=template to call (default: 1)
  |what to separate the entries with (unnamed parameter; required, but can be the empty string)
  |pc1n=name of first parameter with constant value (default: the value of parameter u)
  |pc1v=first constant value (default: empty)
  |pc2n=name of second parameter with constant value (default: the value of parameter u)
  |pc2v=second constant value (default: empty)
  |pc3n=name of third parameter with constant value (default: the value of parameter u)
  |pc3v=third constant value (default: empty)
  |pc4n=name of fourth parameter with constant value (default: the value of parameter u)
  |pc4v=fourth constant value (default: empty)
  |pc5n=name of fifth parameter with constant value (default: the value of parameter u)
  |pc5v=fifth constant value (default: empty)
  |pv=name of variable parameter (default: 1)
  |prefix=constant first part of the value of pv (default: empty)
  |postfix=constant last part of the value of pv (default: empty)
  |list of 0 to 150 parameter values (without prefixes and postfixes), with separator "|"
     (empty parameter values work in the regular way, they are ''not'' ignored like undefined ones)
  |u=name of a parameter that is not used in template ''call'' (default: empty; see also below)

}}

The separator is unnamed, allowing it to start and/or end with newlines and spaces. This parameter should be put before the list. If a parameter value in the list contains an equals sign the list should use named parameters, at least from that point, where it should be noted that e.g. the third item in the list is parameter 4, because parameter 1 is the separator. If the separator contains an equals sign then represent it with {{=}}.

Example

No template call, just render the list of templates

We can create a table with the for template.

Test
ShotgunShotgun
1 .00%



MinigunMinigun
2 .00%



Hat of Undeniable Wealth and RespectHat of Undeniable Wealth And Respect
97 .00%



{|class="wikitable sortable"
|-
! colspan="3" style="background:#F3A957;" | Test
|-
{{for
 |
 |{{Crate series table/row|item=Shotgun|rate=1}}
 |{{Crate series table/row|item=Minigun|rate=2}}
 |{{Crate series table/row|item=Hat of Undeniable Wealth and Respect|rate=97}}
}}

Call with a template

The template being called is "1", which just returns the inputs. The separator is ", ".

a, b, c

{{for|, |call=1|a|b|c}}