admin管理员组

文章数量:1245873

This is the error in my jade template:

     Error: E:\Do\hello_express\node_notes\views\simple.jade:6
    4|      meta(charset="utf-8")
    5|      meta(name="viewport",content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no")
  > 6|      meta(http-equiv="X-UA-Compatible",content="IE=edge")    
    7|      title= #{title}
    8|      link(rel='stylesheet',href='.2.0/css/bootstrap.min.css')
    9|      link(rel='stylesheet',href='stylesheets/notes.css')

    unexpected text     
        t

My template looks like this:

html
    head
        meta(charset="utf-8")
        meta(name="viewport",content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no")
        meta(http-equiv="X-UA-Compatible",content="IE=edge")    
        title= #{title}
        link(rel='stylesheet',href='.2.0/css/bootstrap.min.css')
        link(rel='stylesheet',href='stylesheets/notes.css')
        script(type='text/javascript',src='.1.1/jquery.min.js')
        script(type='text/javascript',src='.2.0/js/bootstrap.min.js')
    body
        block content   

This is the error in my jade template:

     Error: E:\Do\hello_express\node_notes\views\simple.jade:6
    4|      meta(charset="utf-8")
    5|      meta(name="viewport",content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no")
  > 6|      meta(http-equiv="X-UA-Compatible",content="IE=edge")    
    7|      title= #{title}
    8|      link(rel='stylesheet',href='http://maxcdn.bootstrapcdn./bootstrap/3.2.0/css/bootstrap.min.css')
    9|      link(rel='stylesheet',href='stylesheets/notes.css')

    unexpected text     
        t

My template looks like this:

html
    head
        meta(charset="utf-8")
        meta(name="viewport",content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no")
        meta(http-equiv="X-UA-Compatible",content="IE=edge")    
        title= #{title}
        link(rel='stylesheet',href='http://maxcdn.bootstrapcdn./bootstrap/3.2.0/css/bootstrap.min.css')
        link(rel='stylesheet',href='stylesheets/notes.css')
        script(type='text/javascript',src='http://cdnjs.cloudflare./ajax/libs/jquery/2.1.1/jquery.min.js')
        script(type='text/javascript',src='http://maxcdn.bootstrapcdn./bootstrap/3.2.0/js/bootstrap.min.js')
    body
        block content   
Share Improve this question edited Jul 21, 2014 at 16:48 Scimonster 33.4k10 gold badges79 silver badges91 bronze badges asked Jul 21, 2014 at 16:41 vamsiampoluvamsiampolu 6,63220 gold badges89 silver badges193 bronze badges 1
  • 1 maybe time to change the accepted answer? – Avraham Commented Aug 30, 2017 at 5:04
Add a ment  | 

2 Answers 2

Reset to default 10

This error is due to blank-space characters at the end of the line.

The error would be due to the title element rather than the meta being pointed to.

For it, you'll either want to use tag= or #{...}, but not both on the same element.

title= title
title #{title}

The 1st form expects the content that follows the = to be a valid JavaScript expression, which #{...} isn't currently considered.

The 2nd form instead treats the content as plain text, with the exception of #{...} sections that Jade allows for interpolating/inserting the results of code.

本文标签: javascriptError unexpected text when using jadeStack Overflow