views:

30

answers:

1

Because I was getting myself annoyed with the HTML tags, I started to convert my project to HAML, since it is a lot better structured. I am glad the installation provides the tool html2haml to help me with it.

While being syntactically correct, processing the file gives me a weird error I don't quite get:

/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

My haml source only has 27 lines, and since I am very new to this, I have no idea where it is gone wrong... here is the code:

%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!"

So yeah, I'd really love to know where this is wrong. Checked it several times, maybe a bug?

Thanks for your time.

A: 

The lines beneath - story.body.split("\n").each do |line| aren't indented. This means that Haml doesn't know to automatically add an end for the block, which is causing the error in question.

nex3
A bug in html2haml, perhaps? Thanks anyway!
Scán
I'm interested in fixing it if it is an html2haml bug. Can you provide the original ERB that was converted into this Haml?
nex3