yegomo
yegomo

Reputation: 297

How to pass a value to Jade template

Please look at following code

user.js

exports.index = function (req, res){
  res.render('user', {
        id: req.params.id
    });
};

user.jade

body
    - var x = #{id}
        div.container
            div.headpic
            if (x < 10)
                img(src='http://domain.com/head/000'+ x + '.png')

I want to pass the value id to x, but show error '500 Unexpected character '#'', so how is the right way to pass the value? thanks.

Upvotes: 3

Views: 347

Answers (1)

TJC
TJC

Reputation: 727

you dont need the #{}. just the id will work

- var x = id

Upvotes: 5

Related Questions