Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pass variables to jade template

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
like image 350
Patricio Carvajal H. Avatar asked Jun 09 '15 15:06

Patricio Carvajal H.


2 Answers

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

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

like image 174
toshiomagic Avatar answered Oct 10 '22 03:10

toshiomagic


Try passing your variables like this

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

And inside your template

#{params.param1}
like image 43
Bidhan Avatar answered Oct 10 '22 05:10

Bidhan