问题
I would like to use a for loop to include jade files each after the other such as slide-1, slide-2, slide-3 etc.
I tried this but it failed:
for(var i = 1; i < 4; i++) {
include('slide-' + i)
}
What's the correct syntax?
Thank you in advance!
回答1:
If you need to iterate a certain number of times, you'd need to define your own function to do so.
html
title Whatup
-function range(start, end) {
- var arr = [];
- for (var i = start; i < end; i++) arr.push(i);
- return arr;
- }
each i in range(1, 4)
include('slide-' + i)
来源:https://stackoverflow.com/questions/43967240/how-to-use-for-loop-including-files-in-jade-pug