相关疑难解决方法(0)

多个多行HAML块

使用HAML的(有意)奇怪的多行格式,我想在我的模板中有以下几行:

= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
  :foo4 => 'bar4', :foo5 => 'bar5' |

-# and

= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
  :foo4 => 'bar4', :foo5 => 'bar5' |
Run Code Online (Sandbox Code Playgroud)

但是,它们不能相互碰撞,或者它们被读作单个多行块.

-# This fails:
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
  :foo4 => 'bar4', :foo5 => 'bar5' |
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
  :foo4 => 'bar4', :foo5 …
Run Code Online (Sandbox Code Playgroud)

haml ruby-on-rails

18
推荐指数
2
解决办法
2万
查看次数

当在Haml中将属性拉伸到多线时,我得到了一个不平衡的括号错误

以下代码unbalanced bracket error在第4行给出了我的信息

%ul
  - @sentences.each do |sentence|
    %li
      %a{id:"s-#{sentence.id}",
      href:"/sentence/#{sentence.id}",
      'data-type' => 'text',
      'data-url' => "/sentence/#{sentence.id}",
      'data-toggle' => 'manual'
      }= sentence.content
      %a{href:'#'}
        %i.icon-pencil



Haml::SyntaxError at /user/1/sentence
Unbalanced brackets.
file: sentences.haml location: nil line: 4
Run Code Online (Sandbox Code Playgroud)

任何的想法?

haml

6
推荐指数
1
解决办法
5446
查看次数

HAML中的多行字符串

因为我不希望我的任何行超过80列,所以我想将最后一行拆分为两行.在行尾添加逗号按照此处的建议工作,但逗号后面会出现逗号.使用HAML有一个很好的清洁方法吗?

- if object.errors.any?
  %section.form_error_message
    %h4.form_error_message__title
      = "#{pluralize(object.errors.size, 'errors')} prevented this form from submitting. Please fix these errors and try again."
Run Code Online (Sandbox Code Playgroud)

我希望所有内容都隐藏在80个列中,就像它们位于此屏幕截图的左侧一样.

在此输入图像描述

haml ruby-on-rails

2
推荐指数
1
解决办法
4331
查看次数

标签 统计

haml ×3

ruby-on-rails ×2