HAML Form For Rails

白昼怎懂夜的黑 提交于 2021-01-27 05:54:27

问题


I'm currently trying to convert an ERB layout to HAML.

This is the error I keep receiving:

index.html.haml:18: syntax error, unexpected ')'
));}\n      #{_hamlout.format_...

Here is the HAML page:

.row-fluid
  .span6
    %h2 Todo List

  .span6
    %h2{:style => "text-align:right;"} <script>document.write(today)</script>

%hr.divider

.row-fluid
  .span6
    %h2.small_head New Task

    = render :partial => 'layouts/form_errors', :locals => {:object => @list}

    .form
      = form_for :list, :url => {:controller => 'lists', :action => 'create'} do |f|
      = label_tag :list_name, "Title", :class => 'header_label' 

I have also tried this as a variation:

= form_for(:list, :url => {:controller => 'lists', :action => 'create'}) do |f|
= label_tag(:list_name, "Title", :class => 'header_label')

Neither work and both generate the same error message, and help greatly appreciated.


回答1:


You need to indent the code in the do block. This should work:

= form_for :list, :url => {:controller => 'lists', :action => 'create'} do |f|
  = label_tag :list_name, "Title", :class => 'header_label' 


来源:https://stackoverflow.com/questions/16430336/haml-form-for-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!