javascript变量进入玉模板 - 服务器端

时间:2015-12-18 06:36:54

标签: javascript node.js express pug

我遇到了玉和快递的麻烦。所以这是serder方面:

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)

之后还有很多,但我不认为它们会有用。提前感谢大家。我借此机会祝你圣诞快乐

1 个答案:

答案 0 :(得分:2)

尝试删除标题后的=符号

应该是

title #{title}