Template:Loop/sandbox
![]() | __EXPECTUNUSEDTEMPLATE__This is the template sandbox page for Template:Loop (diff). See also the companion subpage for test cases. |
Warning | This template is used on approximately 106,000 pages. To avoid major disruption and server load, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
![]() | This template uses Lua: |
This template is used to produce a simple loop. It is based on Module:String, and there is no limit to the number of iterations it can perform.
Usage
<syntaxhighlight lang="wikitext">String Module Error: function rep expects a number as second parameter, received "times to repeat"</syntaxhighlight>
If string contains an equals sign, you must put "|2=string" instead of "|string".
Examples
Code | Output |
---|---|
<syntaxhighlight lang="wikitext" inline>nnnn</syntaxhighlight> | nnnn |
<syntaxhighlight lang="wikitext" inline>test metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest me</syntaxhighlight> | test metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest metest me |
<syntaxhighlight lang="wikitext" inline>2.2517998136852E+15</syntaxhighlight> | 2.2517998136852E+15 |
<syntaxhighlight lang="wikitext" inline>202520252025</syntaxhighlight> | 202520252025 |
<syntaxhighlight lang="wikitext" inline> MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA!</syntaxhighlight> | MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA MUDA! |
When the string being replicated includes "=", we have to precede the second parameter with "<syntaxhighlight lang="wikitext" inline>2=</syntaxhighlight>", or use {{=}}.
Code | Output |
---|---|
<syntaxhighlight lang="wikitext" inline>=========</syntaxhighlight> | ========= |
<syntaxhighlight lang="wikitext" inline>=========</syntaxhighlight> | ========= |
Surrounding whitespace is always stripped; you must use {{#invoke:string|rep}} instead to preserve it.
Code | Output |
---|---|
<syntaxhighlight lang="wikitext" inline> hello hello hello </syntaxhighlight> | hello hello hello |
<syntaxhighlight lang="wikitext" inline>hellohellohello</syntaxhighlight> | hellohellohello |
Template data
TemplateData for Loop
The template is used to produce a simple loop of repeated strings.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Number | 1 | Number of times to repeat | Number | required |
String | 2 | The string to be repeated. Use {{=}} if the string contains an equals sign. | String | required |