node.js + jade – 链接是自闭的,不应该有内容

我指的是MEAN栈上的以下伟大教程。

现在我面临一个模板(JADE)相关的问题,我不能解决:(你可以看看,如果可能的话,帮我。

http://www.ibm.com/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.com/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 

我得到这个例外。 尝试了几个变种,但还没有解决它。

 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.** 

谢谢。

你的问题是这一行:

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

在StackOverflow中看不到它,但在标签后面有一堆空白。

这里显示的空格被replace为_

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

所以你的翡翠会产生如下的东西:

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

这是不允许的,因为<link>元素不允许有子节点。

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

删除title前的空格

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

我和Practical Node.js文本中的一个例子有同样的问题。 根本原因是我的错误 – 在链接定义中使用双引号而不是单引号。 我们面临的挑战是,信息(链接是自动closures,不应该有内容)出现在div声明中,因此非常混乱。 事实certificate,这个错误是在我的包含文件,而不是在玉指示。 行号是正确的,但它显示错误的文件内容。 一旦我find了解决办法,解决起来很简单。
似乎是JADE编译器中的一个错误。