Haml to silnik szablonów HTML wykorzystujący wcięcia do tworzenia czystego kodu bez powtórzeń (DRY).
Podstawy
Doctype
!!!
!!! 5
!!! Strict
!!! Frameset
!!! Mobile
!!! Basic
Znaczniki i struktura
%p Hello World
%span
Inner text
Klasy i identyfikatory
%div#content
%p.highlighted Text content
/ Div is the default tag when omitted
.notice
#login-box
Atrybuty wbudowane
Obsługiwane są obie składnie tablic asocjacyjnych:
%html{ "xml:lang" => "en", :lang => "en" }
%a{ :href => "/login", :title => "Sign in" }
/ HTML-style attributes syntax
%a(href="/login" title="Sign in")
Ewaluacja kodu Ruby
= "Evaluated Ruby expression"
- [1, 2, 3].each do |num|
%li= num