Plain text and interpolation¶
Any line whose first non-space character is not a HAML sigil is plain text. Plain text is emitted as-is at the current indent level.
1 2 3 | |
renders to:
1 2 3 4 | |
Backslash escape¶
To produce text that begins with a HAML sigil, prefix the line with \. The
backslash is stripped from the output.
1 2 3 | |
renders to:
1 2 3 | |
Interpolation¶
#{ ... } evaluates a Raku expression, HTML-escapes the result, and emits it.
1 | |
with :locals(%(name => 'world')) renders to:
1 | |
!{ ... } evaluates and emits the result without HTML-escaping. Use it when
the value is already known-safe HTML.
1 | |
with :locals(%(raw => '<b>bold</b>')) renders to:
1 | |
To produce a literal #{...} or !{...}, escape the leading sigil with a
backslash:
1 | |
renders to:
1 | |
Interpolation is recognized in tag content, plain text lines, and inside double-quoted attribute strings:
1 | |
with :locals(%(id => 7)) renders to:
1 | |
Single-quoted attribute strings are literal — no interpolation is performed:
1 | |
renders to:
1 | |
Escaping rules¶
Inside #{ ... }, the value is HTML-escaped before emission, so user input
cannot inject markup:
1 | |
with :locals(%(tag => '<b>')) renders to:
1 | |
Inside !{ ... }, the value is emitted raw. Inside attribute values, the
final attribute value is escaped once after interpolation, so #{} and
!{} produce equivalent output for attributes.
Multi-line content¶
The legacy | line-continuation operator from Ruby HAML 3 is not
supported. Wrap multi-line content in a tag or use embedded Raku for
formatting:
1 2 3 | |