jpte0w
Last Updated: February 25, 2016
·
3.108K
· hoodwink73
2179d367e8abd41a5dc76e64fb271255

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).

Say Thanks
Respond

1 Response
Add your response

12671
E9c4ce3be9142b637383ad0d14c11fee

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

+times(10)
li

over 1 year ago ·