HTML templating engine for Ruby with indentation-based, end-tag-free markup
open sourceMITfree
Haml (HTML Abstraction Markup Language) is a templating engine for Ruby that replaces ERB's HTML-with-tags with a terser, indentation-based syntax. Elements are written as %tag, ids and classes use CSS-style #id.class shorthand with div as the default, nesting comes from indentation, and closing tags are added for you, while = and - lines run Ruby. It works in Ruby on Rails by adding the gem, with haml-rails switching Rails' generators to Haml, in other Ruby frameworks, and from the command line with haml render. It is MIT licensed and maintained by the Haml team.
Problems it solves
- write Rails views without closing HTML tags and noisy ERB
- a cleaner, indentation-based alternative to ERB templates
- make Rails generators create Haml views instead of ERB
- compile a template file to HTML from the command line
Features
- indentation-based markup with automatic closing tags
- %tag syntax with CSS-style #id and .class shorthand; div is the default tag
- Ruby-style hash or HTML-style attributes
- embedded Ruby with = for output and - for logic
- Rails support by adding the gem; haml-rails replaces ERB generators
- haml render command-line tool to compile templates to HTML
Limitations
- Ruby only: Haml templates need a Ruby runtime to compile
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what Haml does.
- Liquid Safe, customer facing template language for flexible web apps
