问题
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