Express+jade: local variable not available in view

北慕城南 提交于 2019-12-03 23:24:23

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

res.render("index", {title: "Blog"});

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}
Arnaud Rinquin

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)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!