Is it possible to get all locals passed from server in a jade like this:
express:
res.render('index', {
title: 'My Title',
p1: 1,
p1: 2,
p1: 3,
p1: 4
});
jade:
html
head
body
script
var all_locals = _.getLocals(); // all_locals => { title: 'My Title', p1: 1, p1: 2, p1: 3, p1: 4}
You are doing it correct, you can wrap all your variables in one variable, and send it with res.render().
//in express
all_locals = {
title: 'My Title',
p1: 1,
p2: 2,
p3: 3,
p4: 4
};
res.render('upload.jade',{all_locals: JSON.stringify(all_locals)});
//in jade
var all_locals = !{all_locals};
alert(all_locals.title);