I want to render the following using express and jade:
function(output) {
for (i=0;i<output.entities.length;i++){
console.log(output.entities[i].uuid);
}
res.render('errCodes.jade', {title : 'Error Codes', entry: output.entities});
},
the jade looks like so:
items = entry
each item, i in items
li <a href="/#{i}">#{item}</a>
The console log looks nice, but no matter what I try, I can't get the jade page to look nice. At the moment, there are two links that read
[object Object]
[object Object]
which is expected. However, I want two links of the ID to show up, but every time I've tried I either get each character of the ID as its own link, or the aforementioned object, object. Any help would be greatly appreciated.
is your original indentation correct? or is it just here on SO that it looks wrong?
items = entry
each item, i in items
li <a href="/#{i}">#{item}</a> // this should be further right
You can use pure jade to achieve the same:
items = entry
each item, i in items
li
a(href="/#{i}") #{item}
if your array looks like the following
output.entities = [{ uuid: 1234 }, { uuid: 5678 }];
your jade should look like this
items = entry
each item, index in items // iterate over array
li
a(href="/#{index}") #{item.uuid}
index
will be 1,2,3,4,... etc.