pass variables to jade template

19.4k views Asked by At

I am trying to pass variables from page.js to page.jade but for some reason this is not working.

here's my code:

page.js

res.render('page', {param1: 'xxx', param2: 'yyy'} );

page.jade

#{param1}
br
#{param2}
br
2

There are 2 answers

1
toshiomagic On BEST ANSWER

You might be rendering them as tags instead. View your source html post render.

Try using !{param} instead of #{param}.

2
Bidhan On

Try passing your variables like this

res.render('page', {params: {param1: 'xxx', param2: 'yyy'}});

And inside your template

#{params.param1}