Difference between pages "Template:Loop" and "Template:Loop/sandbox"
(Difference between pages)
Jump to navigation
Jump to search
Joelmartin (talk | contribs) m (1 revision imported) |
Joelmartin (talk | contribs) (Created page with "{{Documentation subpage}} <!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE --> {{high-risk|86842}} {{lua|Module:String}} This template is used to produce a simple loop. It is...") |
||
Line 1: | Line 1: | ||
− | {{< | + | {{Documentation subpage}} |
− | {{ | + | <!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE --> |
− | < | + | {{high-risk|86842}} |
− | </ | + | {{lua|Module:String}} |
+ | 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 == | ||
+ | |||
+ | <pre>{{loop|times to repeat|string}}</pre> | ||
+ | |||
+ | If '''string''' contains an equals sign, you must put "|2=string" instead of "|string". | ||
+ | |||
+ | == Examples == | ||
+ | |||
+ | *<code><nowiki>{{loop|4|n}}</nowiki></code> | ||
+ | ;{{loop|4|n}} | ||
+ | |||
+ | |||
+ | *<code><nowiki>{{loop|25|test}}</nowiki></code> | ||
+ | ;{{loop|25|test}} | ||
+ | |||
+ | |||
+ | *<code><nowiki>{{#expr:2{{loop|50|*2}}}}</nowiki></code> | ||
+ | ;{{#expr:2{{loop|50|*2}}}} | ||
+ | |||
+ | |||
+ | When the string being replicated includes "=", we have to precede the second parameter with "2=", or use {{tl|1==}}. | ||
+ | * <code><nowiki>{{loop|9|2==}}</nowiki></code> | ||
+ | ;{{loop|9|2==}} | ||
+ | |||
+ | or: | ||
+ | * <code><nowiki>{{loop|9|{{=}}}}</nowiki></code> | ||
+ | ;{{loop|9|{{=}}}} | ||
+ | |||
+ | |||
+ | *<code><nowiki>{{loop|3|{{CURRENTYEAR}}}}</nowiki></code> | ||
+ | ;{{loop|3|{{CURRENTYEAR}}}} | ||
+ | |||
+ | <nowiki>*</nowiki> If string contains an equals sign, you must put '|2=string' instead of '|string'. | ||
+ | |||
+ | ==Template data== | ||
+ | {{TemplateDataHeader}} | ||
+ | <templatedata> | ||
+ | { | ||
+ | "description": "The template is used to produce a simple loop of repeated strings.", | ||
+ | "params": { | ||
+ | "1": { | ||
+ | "label": "Number", | ||
+ | "description": "Number of times to repeat", | ||
+ | "type": "number", | ||
+ | "required": true | ||
+ | }, | ||
+ | "2": { | ||
+ | "label": "String", | ||
+ | "description": "The string to be repeated. Use {{=}} if the string contains an equals sign.", | ||
+ | "type": "string", | ||
+ | "required": true | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </templatedata> | ||
+ | |||
+ | ==See also== | ||
+ | *{{lt|For loop}} | ||
+ | *{{lt|Simple recursion}} | ||
+ | |||
+ | <includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox|| | ||
+ | [[Category:Wikipedia formatting and function templates|{{PAGENAME}}]] | ||
+ | |||
+ | }}</includeonly> |