当前位置: 动力学知识库 > 问答 > 编程问答 >

node.js - Syntax Error: /home/fzxa/work/blog2/views/articles/index.jade:7

问题描述:

I am getting syntax error at line 7 of my Jade template:

 5| div#articles

6| - if(articles.length)

7| !=partial('article_list', {collection : articles, as : 'article'})

8| - else

9| #no-results No articles found. Create one

10| a(href="/articles/new") here

Does anyone know why?

网友答案:

I found this possibly-similar issue on Github. https://github.com/visionmedia/jade/issues/81

You could try tossing in a line like cly does in that article to see if that fixes it:

 5| div#articles
 6|   - if(articles.length)
 7|     !=partial('article_list', {collection : articles, as : 'article'})
  |     #filler
 8|   - else
 9|     #no-results No articles found. Create one
10|       a(href="/articles/new") here
网友答案:

The issue is in the article_list partial view. The code is using the word "class" which is reserved. In article_list.jade change

- if(lastInCollection)
  - class = 'last'
- else
  - class = ''
div(class="article #{class}")

to

- if(lastInCollection)
  - cls = 'last'
- else
  - cls = ''
div(class="article #{cls}")
分享给朋友:
您可能感兴趣的文章:
随机阅读: