问题描述:

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}")
相关阅读:
Top