I decided this week that I\'d like to learn Node.js (I\'m not a programmer). I\'ve been having a lot of fun with it so far but I\'m stuck at the moment.
I\'ve create
I JSON.stringify()
any objects that my client scripts need and insert it as HTML5 data-whatever
attributes.
For example:
//app.js
app.get('/map', function(req, res){
var data = {
id: '1234',
LL: {
lat: 42.1,
lng: 80.8,
};
res.locals.docsJSON = JSON.stringify([data]);
res.render('locations/index');
});
//jade
!!!
html
body(data-locations=locals.docsJSON)
script
var docs = JSON.parse($('body').attr('data-locations'));
console.log(docs[0].LL);