问题
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?
回答1:
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
回答2:
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}")
来源:https://stackoverflow.com/questions/8305817/syntax-error-home-fzxa-work-blog2-views-articles-index-jade7