Multiline HAML Statement
February 24th, 2009 cschneidUpdate: Haml 2.2 has added native multiline attributes, so the example below is still valid syntax, but unnecessary. The pipe syntax can still be used for other spots where multiline is needed though.
Something I hate is the line that goes off into infinity on the right of my editor. And of course, too often, it’s in my HAML code, where it’s totally non-obvious how to break a line into several parts.
The answer is straight forward though. Just end each line of the statement (first, last, and everything in between!) with a pipe | character.
= { :foo => :bar, | :baz => :foo, | :quux => :zz}.inspect |