Indentation

HAML uses indentation to express nesting. A line that's indented further than the previous line becomes a child of that line; a line at the same indent is a sibling; a line at a shallower indent closes one or more parents.

Two-space indent#

Template::HAML currently expects two-space indentation:

%section.container
  %h1 Title
  %ul
    %li Foo
    %li Bar
<section class='container'>
  <h1>Title</h1>
  <ul>
    <li>Foo</li>
    <li>Bar</li>
  </ul>
</section>

Inconsistent indentation is rejected#

An odd-spaced indent is rejected with X::IllegalIndent:

%section
   %h1 Title
Illegal indentation