Loops demo

From Notaclue Wiki
Extension demonstration (infobox template)
Loops
Documentation

on mediawiki.org

Maintained by WikiTeq?

No

Version

This wiki has the Loops extension installed, which adds the ability to "loop" through wikitext multiple times in combination with the Variables extension.

Code Output Explanation
{{#loop: bottles
 | 1
 | 5
 | <nowiki />
* {{#expr: 100 - {{#var:bottles}} }} bottles of beer...
}}
  • 99 bottles of beer...
  • 98 bottles of beer...
  • 97 bottles of beer...
  • 96 bottles of beer...
  • 95 bottles of beer...
The variables bottles goes through 5 iterations starting with
1 and for each iteration the wikitext is processed
{{#vardefine:s|a}} {{#while:
 | {{#ifexpr: ({{#len: {{#var:s}}}}) < 5 | true }}
 | <nowiki />
* {{#var: s }}{{#vardefine: s | {{#var:s}}a }} }}
  • a
  • aa
  • aaa
  • aaaa
As long as the length of variable str is less than 5 it is
printed and then lengthened

See also[edit | edit source]

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