jhc*_*hen 19 ruby haml word-wrap
如何在HAML中为单个Ruby语句使用多行?例如,我想写下面的内容:
- entries = [{
- :title => "The Fellowship of the Ring",
- :body => "We should walk instead of fly"
- }]
!!! 5
%html
%head
%title Blog
%body
#content
- entries.each do |entry|
.entry
%h3.title= entry[:title]
%p.body= entry[:body]
Run Code Online (Sandbox Code Playgroud)
但当然前四行会产生语法错误.
Tod*_*obs 37
根据HAML常见问题解答:
[W]如果函数有很多参数,只要每行以逗号结尾,就可以将它包装在多行中.
所以,以下应该是有效的HAML:
- entries = [{ :title => "The Fellowship of the Ring",
:body => "We should walk instead of fly" }]
Run Code Online (Sandbox Code Playgroud)
小智 5
You can use :ruby filter.
:ruby
entries = [{
:title => "The Fellowship of the Ring",
:body => "We should walk instead of fly"
}]
!!! 5
%html
%head
%title Blog
%body
#content
- entries.each do |entry|
.entry
%h3.title= entry[:title]
%p.body= entry[:body]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9598 次 |
| 最近记录: |