Express+jade: local variable not available in view

前端 未结 3 2286
迷失自我
迷失自我 2021-02-19 03:41

I ran into a very basic problem but I can\'t seem to find the answer to it. I am working with node.js, express and I am just trying to pass a local var

相关标签:
3条回答
  • 2021-02-19 04:20

    You should pass the variable without the locals. This is probably new in express 3.0.0

    res.render("index", {title: "Blog"});
    
    0 讨论(0)
  • 2021-02-19 04:21

    Here is a response that I made few hours ago to a smiliar question (+ deal with layout). It shows how to pass data when rendering. (Express 3.0.0 complient)

    0 讨论(0)
  • 2021-02-19 04:35

    h1 = title tries to evaluate it locally, the title you sent and that one is different. To understand the difference see:

    - var title = 'my title' // - allows writing code
    h1 = title
    

    The one you should use is:

    h1 #{title}
    
    0 讨论(0)
提交回复
热议问题