On my Node.js sever, I have an array of JavaScript objects that were given to me by a MySQL query. I need to send that Array to my Jade template, so I do this in my router.js:
data = JSON.stringify(rows[0]);
res.render('yourUploads', {fromServer:data});
console.log(data) reads something like this: [{key:val},{key:val},{key:val}]
Now I'm trying to iterate over this object in Jade like so:
- for (object in JSON.parse(fromServer)) {
+posMixin(object.toString())
- }
object.toString() just gives me "0", "1", "2" object.val seems to be null.
I thought this was a duplicate of how to render json object in jade and loop through results, but I'm dealing with this Array of json instead of json. This is a lot like Passing an array to a JSON object for Jade rendering, but I'm trying to use a mixin and run sever-side rendering, not move it in to JavaScript.
via Glen Pierce
No comments:
Post a Comment