Reputation: 28
I am busy learning the templating language JADE, and I can't seem to figure out how to do for
loops.
Currently I have the following code:
- for (var i = 0; i < 10; ++i) {
p #{var}
- }
I'm trying to output the value of var
in a p
tag ten times.
Upvotes: 0
Views: 2814
Reputation: 16602
you should use the jade syntax to loop over an array: http://jade-lang.com/reference/iteration/
for instance:
ul
each val in [1, 2, 3, 4, 5]
li= val
and as Alejo already said, you cannot use var
as a variable in jade, because it's a JavaScript keyword.
Upvotes: 0
Reputation: 393
The word var
is a keyword in Javascript. Jade is written in Javascript. There is no variable, var
, the definition to create variables is
var [NameOfMyVariable] = [TheDataIntoMyVariable];
This being so, what you intend is to obtain an iteration of a variable. which in this case is i
,
- for (var i = 0; i < 10; ++i) {
p #{i}
- }
Upvotes: 1