Loops demo
From Notaclue Wiki
| Loops | |
|---|---|
| Documentation | |
| 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...
}}
|
|
The variables bottles goes through 5 iterations starting with1 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 }} }}
|
|
As long as the length of variable str is less than 5 it isprinted and then lengthened |