Whitespace operators
Template::HAML supports HAML's whitespace-removal modifiers and whitespace-preservation behaviors so you can control how generated HTML is laid out.
Outer trim >
A trailing > on a tag strips whitespace immediately around the tag, both before its open tag and after its close tag.
| %p first
%p> middle
%p last
|
| <p>first</p><p>middle</p><p>last</p>
|
This works for any tag, including void elements:
Inner trim <
A trailing < on a tag strips whitespace immediately inside the tag, both after the open tag and before the close tag.
| <blockquote><div>
Foo!
</div></blockquote>
|
When combined with content on the same line plus a single child, the child renders inline:
| <p>hello<strong>world</strong></p>
|
Combined <> / ><
Both modifiers can be combined in either order:
The pre and textarea elements automatically preserve their inner whitespace by replacing newlines with the 
 HTML entity. This keeps the rendered display intact while still allowing HAML to indent the source.
| <pre>
 Line 1
 Line 2
</pre>
|
The list of preserved elements is configurable via the preserve option on Template::HAML::Config:
| my $cfg = Template::HAML::Config.new(:preserve('pre', 'textarea', 'code'));
HAML.render(:src($haml), :config($cfg));
|
Global whitespace removal
To apply > and < to every tag at once, set remove-whitespace: True on the
config. See Configuration for details. Preserved
tags keep their inner whitespace but still have outer whitespace stripped.
Forced preserve ~
The ~ operator works like = (eval and emit), but additionally replaces newlines in the result with 
. This is useful when an interpolated string contains newlines you want to keep literal in the rendered output.
Like =, the result is HTML-escaped by default. Disable escaping globally with escape_html => False on the config.