【发布时间】:2010-10-19 16:37:57
【问题描述】:
因为我对 HTML 标签感到恼火,所以我开始将我的项目转换为 HAML,因为它的结构要好得多。我很高兴安装提供了工具html2haml 来帮助我。
虽然语法正确,但处理文件会给我一个奇怪的错误,我不太明白:
/stories/_story.html.haml:28: syntax error, unexpected keyword_ensure, expecting keyword_end
...:Util.html_safe(_erbout);ensure;@haml_buffer = @haml_buffer....
... ^
/stories/_story.html.haml:31: syntax error, unexpected $end, expecting keyword_end
我的 haml 源代码只有 27 行,由于我对此很陌生,所以我不知道哪里出了问题……这是代码:
%h1= story.title
%center
%i
by #{link_to story.user.name, story.user}
#story-short= story.short_desc
- if logged_in? and @current_user.id == story.user_id
.list-buttons
%center
= link_to 'Edit', edit_story_path(story)
|
\#{link_to 'Delete', story, :method => 'delete', :confirm => 'Are you really sure?'}
#story-body
- story.body.split("\n").each do |line|
- if line.strip.empty?
%hr/
- else
%p= line.strip
#comments
%p{:onclick => "$('#comments').find('dl').slideToggle();"} Comments to this story (click to expand)
%dl
= render :partial => 'comment', :collection => @story.comments
- if logged_in? and @current_user.id != story.user_id
%dt Leave a comment:
%dd
= form_for [story, story.comments.build] do |f|
.field= f.text_area :body
.actions= f.submit "Comment!"
所以是的,我真的很想知道这是哪里错了。查了好几遍,可能是bug?
感谢您的宝贵时间。
【问题讨论】:
标签: ruby-on-rails haml