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
Post a Comment