使用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) 以下代码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)
任何的想法?
因为我不希望我的任何行超过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个列中,就像它们位于此屏幕截图的左侧一样.