HAML Rails表格 [英] HAML Form For Rails

查看:59
本文介绍了HAML Rails表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试将ERB布局转换为HAML.

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_...

这是HAML页面:

.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' 

我也尝试过这样做:

= 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.

推荐答案

您需要在 do 块中缩进代码.这应该起作用:

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' 

这篇关于HAML Rails表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆