简体   繁体   中英

javascript variable into jade template - server side

i'm having some troubles with jade and express. So this is the serder side:

router.get('/login', function (req, res) {
   res.status(200)
   res.render('login',{title:'login'})
   res.end()
});

This is my jade:

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

And, of course, these are my errors:

  > 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)

and a lot more after but i don't think that they will be usefull. Thank you in advance to everyone. I take this opportunity to wish you a merry xMas

Try removing the = sign after title

It should be

title #{title}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM