Reputation: 7965
I'm trying to load some variables with res render like that:
res.render('blog_edit', {title: 'edit your blog', posts: "something"});
though title loads fine post always appears as undefined... here are some of the ways I tried...
=posts
#{posts}
and as a javascript variable
script
document.write(posts)
none of them is working... can you please help? thanks in advance
Upvotes: 15
Views: 37386
Reputation: 11
Here is what works for me.
in JS
res.render('index', {email: req.params.email});
in Jade
#{locals.email}
Upvotes: 0
Reputation: 11425
I'm using the latest versions today ("express": "4.11.2", "jade": "1.9.2") and this is the syntax that works for me:
res.render('blog_edit', {title: 'edit your blog', posts: "something"});
In template:
#{locals.posts}
or
#{posts}
Upvotes: 7
Reputation: 25769
try
res.render('blog_edit', {locals:{title: 'edit your blog', posts: "something"}});
#{locals.foo}
Upvotes: 21