vendredi 27 février 2015

Jade Mixin for List

I'm trying to create a jade mixin where I can input the number of items in a list.


Example,



mixin list(n, text)
.list
a(href="#") #{text}
a(href="#") #{text}
.....n times


If I call the mixin like this



+list(4, 'hello')


the outputted html should resemble:



<div class="list">
<a href="#">hello</a>
<a href="#">hello</a>
<a href="#">hello</a>
<a href="#">hello</a>
</div>


How could I achieve this (with a loop)?


Aucun commentaire:

Enregistrer un commentaire