admin管理员组

文章数量:1287859

I'm referring the following great tutorial on MEAN stack.

Now I'm facing a template(JADE) related issue which I'm not able to resolve :( Can you plz have a look and help me if possible.

/

    doctype 5
    html(lang='en')
      head
        meta(charset='utf-8')
        meta(name='viewport', content='width=device-width, 
initial-scale=1, user-scalable=no')
        title= title
        link(rel='stylesheet', href='//netdna.bootstrapcdn/bootstrap/3.0.1/
css/bootstrap.min.css')
        link(rel='stylesheet', href='/stylesheets/style.css')                
      body
        nav.navbar.navbar-inverse.navbar-fixed-top(role='navigation')
          div.navbar-header
            a.navbar-brand(href='#/polls')= title
        div.container
          div

I'm getting this exception. Tried couple of varitions but couldn't resolve it yet.

Error: C:\DevEnv\UT3_Node\HelloWorldNodeProject\views\index.jade:14
    12|         a.navbar-brand(href='#/polls')= title
    13|     div.container
  > 14|       div

**link is self closing and should not have content.**

Thanks in adv.

I'm referring the following great tutorial on MEAN stack.

Now I'm facing a template(JADE) related issue which I'm not able to resolve :( Can you plz have a look and help me if possible.

http://www.ibm./developerworks/library/wa-nodejs-polling-app/

    doctype 5
    html(lang='en')
      head
        meta(charset='utf-8')
        meta(name='viewport', content='width=device-width, 
initial-scale=1, user-scalable=no')
        title= title
        link(rel='stylesheet', href='//netdna.bootstrapcdn./bootstrap/3.0.1/
css/bootstrap.min.css')
        link(rel='stylesheet', href='/stylesheets/style.css')                
      body
        nav.navbar.navbar-inverse.navbar-fixed-top(role='navigation')
          div.navbar-header
            a.navbar-brand(href='#/polls')= title
        div.container
          div

I'm getting this exception. Tried couple of varitions but couldn't resolve it yet.

Error: C:\DevEnv\UT3_Node\HelloWorldNodeProject\views\index.jade:14
    12|         a.navbar-brand(href='#/polls')= title
    13|     div.container
  > 14|       div

**link is self closing and should not have content.**

Thanks in adv.

Share Improve this question asked Dec 28, 2013 at 18:30 user19user19 552 silver badges7 bronze badges 1
  • a.navbar-brand(href='#/polls')= title remove space before title – vittore Commented Dec 28, 2013 at 18:33
Add a ment  | 

3 Answers 3

Reset to default 8

Your problem is this line:

link(rel='stylesheet', href='/stylesheets/style.css')                

You can't see it very well on StackOverflow, but you have a bunch of whitespace after the tag.

The whitespace is shown here replaced with _:

link(rel='stylesheet', href='/stylesheets/style.css')________________

So your Jade would generate something like:

<link rel="stylesheet" href="/stylesheets/style.css">________________</link>

which is not allowed, since <link> elements are not allowed to have child nodes.

a.navbar-brand(href='#/polls')= title 

remove space before title

a.navbar-brand(href='#/polls')=title 

I had the same issue with one of the examples in the Practical Node.js text. The root cause was my error - using double quotes in a link definition instead of single quotes. The challenge was that the message (link is self closing and should not have content.) was appearing on a div statement and hence was very confusing. It turns out that the error was in my include file rather than where jade indicated. The line number was correct, but it was showing the wrong file content. Once I had that figured out, the fix was easy.
Seems to be a bug in the JADE piler.

本文标签: javascriptnodejsjadelink is self closing and should not have contentStack Overflow