javascript jade 模板中的变量 - 服务器端
javascript variable into jade template - server side
我在使用 jade 和 express 时遇到了一些麻烦。所以这是服务端:
router.get('/login', function (req, res) {
res.status(200)
res.render('login',{title:'login'})
res.end()
});
这是我的玉:
doctype html
html(lang='en')
head
meta(charset='UTF-8')
meta(name='viewport', content='width=device-width')
title= #{title}
block css
link(rel='stylesheet', href='/css/style.css')
block js
//script(src='../public/js/')
script(src='http://localhost:35729/livereload.js')
body
block content
当然,这些是我的错误:
> 7| title= #{title}
8| block css
9| link(rel='stylesheet', href='/css/style.css')
10| block js
Unexpected token ILLEGAL
at Function (native)
at assertExpression (/Users/VeaVictis/iGym/node_modules/jade/lib/lexer.js:30:3)
at Object.Lexer.code (/Users/VeaVictis/iGym/node_modules/jade/lib/lexer.js:584:23)
之后还有很多,但我认为它们不会有用。提前谢谢大家。借此机会祝您圣诞快乐
尝试删除标题后的 = 号
应该是
title #{title}
我在使用 jade 和 express 时遇到了一些麻烦。所以这是服务端:
router.get('/login', function (req, res) {
res.status(200)
res.render('login',{title:'login'})
res.end()
});
这是我的玉:
doctype html
html(lang='en')
head
meta(charset='UTF-8')
meta(name='viewport', content='width=device-width')
title= #{title}
block css
link(rel='stylesheet', href='/css/style.css')
block js
//script(src='../public/js/')
script(src='http://localhost:35729/livereload.js')
body
block content
当然,这些是我的错误:
> 7| title= #{title}
8| block css
9| link(rel='stylesheet', href='/css/style.css')
10| block js
Unexpected token ILLEGAL
at Function (native)
at assertExpression (/Users/VeaVictis/iGym/node_modules/jade/lib/lexer.js:30:3)
at Object.Lexer.code (/Users/VeaVictis/iGym/node_modules/jade/lib/lexer.js:584:23)
之后还有很多,但我认为它们不会有用。提前谢谢大家。借此机会祝您圣诞快乐
尝试删除标题后的 = 号
应该是
title #{title}