How do I wrap multiline Ruby arguments in HAML?

Wrap Arguments with Commas

According to the HAML FAQ:

[W]hen a function has lots of arguments, it’s possible to wrap it across multiple lines as long as each line ends in a comma.

So, the following should be valid HAML:

- entries = [{ :title => "The Fellowship of the Ring", 
               :body  => "We should walk instead of fly" }]

%div= "First line " + |
      "and second line" |

Will render:

<div>First line and second line</div>

You can use the command-tool haml, for instance copy the code then pbpaste | haml on macOS, or with a file cat file.haml | haml.

If you don't even want a tag:

First line |
and second line |

Will produce:

First line and second line

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]

Check out the docs here.

Note that it's intentionally awkward because you're not supposed to be putting lots of ruby in your templates.