在haml部分模板处理中缺少keyword_end

Scá*_*cán 9 haml ruby-on-rails

因为我对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
Run Code Online (Sandbox Code Playgroud)

我的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!"
Run Code Online (Sandbox Code Playgroud)

所以,是的,我真的很想知道这是错的.检查了几次,也许是一个bug?

谢谢你的时间.

Nat*_*aum 10

下面的线- story.body.split("\n").each do |line|没有缩进.这意味着Haml不知道end为块自动添加一个,这导致了有问题的错误.