2010-10-19 5 views
9

Poiché mi sono infastidito con i tag HTML, ho iniziato a convertire il mio progetto in HAML, poiché è molto meglio strutturato. Sono contento che l'installazione fornisca lo strumento html2haml per aiutarmi.Manca keyword_end sull'elaborazione parziale template haml

Pur essendo sintatticamente corretto, me l'elaborazione del file dà un errore di strano non ho ben capito:

/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 

La mia fonte Haml ha solo 27 linee, e da allora sono molto nuovo a questo, ho idea di dove sia andato storto ... ecco il codice:

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

Quindi sì, mi piacerebbe davvero sapere dove questo è sbagliato. Controllato più volte, forse un bug?

Grazie per il vostro tempo.

risposta

9

Le righe inferiori a - story.body.split("\n").each do |line| non sono rientrate. Ciò significa che Haml non sa di aggiungere automaticamente un end per il blocco, che sta causando l'errore in questione.

+1

Un errore in html2haml, forse? Grazie comunque! –

+0

Sono interessato a ripararlo se si tratta di un bug html2haml. Potete fornire l'ERB originale che è stato convertito in questo Haml? –