I would suggest a slightly different approach: convert the array into a two-dimensional array into a request handler function, and then iterate over the two-dimensional array (array of arrays) in your Jade template.
With this approach, the template will be much simpler, and all conversions will occur inside the handler (controller) method, where you can have access to different libraries, etc.
Example: To convert an array to a two-dimensional array, you can use the following method:
function arrayTo2DArray (list, howMany) {
var result = []; input = list.slice(0);
while(a[0]) {
result.push(a.splice(0, howMany));
}
return result;
}
:
exports.handler = function(req, res) {
res.render('template' {
myArray: arrayTo2DArray(myArray, 4)
}
}
myArray , , ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], arrayTo2DArray(myArray, 4)
[
['a', 'b', 'c', 'd'],
['e', 'f', 'g', 'h']
]
Jade ( )
each values in myArray
+carouselItem(values)
, .