I'm gonna keep this short. I have this code:
- var title = 'title'
block content
h1= title
p Welcome to #{title}
Why does this not work? I have tried it without the variable and it works perfectly the, so the problem is about the variable.
The problem was that since index.jade extended layout, when I defined the variable inside index.jade and then referenced it inside the block content, the references to it came before the definition.
The fix is simple: either define the variable in block content too:
block content
- var title = 'title'
h1= title
p Welcome to #{title}
Or if you want it to be able to the layout.jade too, just define it at the top of layout.jade.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.