pass variables to jade template

19.5k 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 best solutions below

1
On BEST ANSWER

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

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

2
On

Try passing your variables like this

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

And inside your template

#{params.param1}