Error: haml syntax error, unexpected keyword_ensure awaiting $ end

Redid a new development session from erb to Haml, but it does not work, this is the code:

%div.row.show-grid %div.span8.offset7 %h1 Sign in - form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %div.clearfix = f.label :email %div.input = f.email_field :email, :class => 'xlarge', :id => 'admin_email' %div.clearfix = f.label :password %div.input = f.password_field :password, :class => 'xlarge', :id => 'admin_password' - if devise_mapping.rememberable? %div = f.check_box :remember_me = f.label :remember_me %div = f.submit "Sign up" 

and this is the erb source code:

 <div class="row show-grid"> <div class="span8 offset7"> <div class="page-header"> <h1>Sign in</h1> </div> <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> <div class="clearfix"> <%= f.label :email %> <div class="input"> <%= f.email_field :email, :class => 'xlarge', :id => 'admin_email' %> </div> </div> <div class="clearfix"> <%= f.label :password %> <div class="input"> <%= f.password_field :password, :class => 'xlarge', :id => 'admin_password' %> </div> </div> <% if devise_mapping.rememberable? -%> <div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div> <% end -%> <div><%= f.submit "Sign up" %></div> <% end %> 
+4
source share
1 answer

First you can directly use .class and #id , this is a shortcut for %div.class and %div#id

Secondly, this error is usually triggered in a "block" of code, as in:

 - if cond =# instr 

or

 - form_for(options) do |f| =# instr 

Providing us with an error string will help. But I would say that you messed up the indentation in one of the blocks of code.

EDIT

Oh, I get it. You forgot the indentation line 7, = f.label :email . In addition, %tag = code will not work, you need to either attach it or do it with %tag= code

+6
source

Source: https://habr.com/ru/post/1390977/


All Articles