Passing objects between nodejs and jade

I have the following code in my server.js

  var cddata = [];
  body.rows.forEach(function(doc) {
  cddata.push([{id: doc.id, name: doc.key, text:doc.value.Time, group: 1}]);              
  });
  response.render('timeline', {cddata: JSON.stringify(cddata)});

and I have the following in my Jade view file

script(src='vis/dist/vis.js')        
link(rel="stylesheet", href="vis/dist/vis.css", type="text/css")

script.
    //alert(cddata);    
    var options = {};
    var data = new vis.DataSet(cddata);
    var container = document.getElementById('visualization');
    new vis.Timeline(container, data, options);

However, nothing related to the chart is rendered. I presume the object is not correctly passed to the jade file. Please help!

Also, is there a way to verify the incoming object in Jade? Alerts dont seem to work. thanks

The <script> in your jade is a browser side script so won't be able to access variables in the templates generation scope. You'll need to output your data as JSON and read it in using browser side JavaScript, something like this:

script(src='vis/dist/vis.js')        
link(rel="stylesheet", href="vis/dist/vis.css", type="text/css")

script.
    var chartData = JSON.parse('#{cddata}')
    var options = {};
    var data = new vis.DataSet(chartData);
    var container = document.getElementById('visualization');
    new vis.Timeline(container, data, options);

After much deliberation, the following worked to pass object from node server to client side server scripting on Jade file.

on the server.js, where dbdata is an array of JSON objects

response.render('timeline', {dbdata:dbdata});

On the jade file,

script. var chartData = !{JSON.stringify(dbdata)};

Thanks,