node.js - For loop in Swig template engine -



node.js - For loop in Swig template engine -

i'm using swig template engine express.js , found no way create loop variable so:

for(var i=0; i<100; i++){ //whatever }

is possible?

as posted on github issue same question, loops don't exist in swig. can iterate on actual objects , arrays, however. (see for-tag documentation).

otherwise, create range helper, discussed here

swig.setdefaults({ locals: { range: function (start, len) { homecoming (new array(len)).join().split(',').map(function (n, idx) { homecoming idx + start; }); } }});

node.js express swig-template

Comments

Popular posts from this blog

javascript - I need to update the text of a paragraph by inline edit -

javascript - THREE.js reposition vertices for RingGeometry -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -