help with displaying a variable in jade express


Question

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

1
16
8/23/2011 7:54:33 PM

Accepted Answer

try

  res.render('blog_edit', {locals:{title: 'edit your blog', posts: "something"}});

        #{locals.foo}
22
8/23/2011 12:37:40 PM

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}

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon