loop.pug – Recursive HTML generation

View source code on Github

Include blocks X times

mixin loop(count)
  - var n = 0
  while n < count
    block
    - n++
+loop(count)

Insert a block inherited from this mixin a defined number of times.

Arguments:
  • count (int) – Number of reptetitions of the inherited block.

Usage

Input

+loop(3)
  a(href="#") 3 links

Output

<a href="#">3 links</a>
<a href="#">3 links</a>
<a href="#">3 links</a>

Render

3 links 3 links 3 links