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.

有帮助吗?

解决方案

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

- var x = id
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top