Last Updated: February 25, 2016
·
3.743K
· hoodwink73

Get quicker at creating repeating elements with Jade

Sometimes when prototyping, we may just need the tags to repeat themselves without any content inside them, so that we create something out of them just through plain css.

Example

ul
  li
  li
  li

With jade you have to write

ul
each i in [1, 2, 3]
  li

What if say, you need an arbitrarily large number of repeating elements?

Instead of writing [1,2,3,4,....]

You can code

ul
each i in new Array(10)
  li

This will get you 10 li elements (but the value of i for every element will be undefined).

1 Response
Add your response

You can also use one of the mxins I've written at https://coderwall.com/p/3fgarg

+times(10)
li

over 1 year ago ·