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

只愿长相守 提交于 2019-12-25 02:22:00

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!