Masiar Masiar - 1 year ago 71
Node.js Question

Jade template, how to pass concrete object to pages?

I have a jade template for my node.js project. I would like to send an object to the jade template and pass it to a function inside the page (to render something).

I am sure I send the right stuff from the server like this

res.render(__dirname + '/pages/viz.jade', {
vizJson: newJson,

in the client I do something like this:


Thus, inside a script function, I want to call a function that creates my visualization with some json I created on the server side.

The problem is that when rendered I have something like
sunburst([Object object])
. I also tried to send the stringified version of the JSON but when I do
it complains like
Unexpected token &

The json I send is always different and has different level of depths.

Does anyone knows what to do?


Answer Source

I hope this is going to help someone. I solved it like this:


Notice the ! and the {...} wrapping the stringify method.