简体   繁体   English

错误:haml语法错误,意外的keyword_ensure,期待$ end

[英]Error: haml syntax error, unexpected keyword_ensure, expecting $end

Have converted devise new session from erb to Haml but doens't work, this is the code: 已经转换设计从erb到Haml的新会话但是没有用,这是代码:

%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 originally erb code: 这是最初的erb代码:

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

First, you can use .class and #id directly, they're a shortcut for %div.class and %div#id 首先,您可以直接使用.class#id ,它们是%div.class%div#id %div.class的快捷方式

Second, this error is usually triggered in a "block" of code, as in: 其次,此错误通常在代码的“块”中触发,如:

- if cond
  =# instr

or 要么

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

Giving us the error line would help. 给我们错误线会有所帮助。 But I'd say you messed up with indentation in one of said code blocks. 但是我会说你在其中一个代码块中搞砸了缩进。

EDIT 编辑

Oh I get it. 哦,我明白了。 You forgot to indent line 7, = f.label :email . 你忘了缩进第7行, = f.label :email Also, %tag = code won't work, you have to either nest it, or do it with %tag= code 另外, %tag = code不起作用,你必须嵌套它,或者用%tag= code来做

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM