haml
templating language that compiles to HTML
TLDR
SYNOPSIS
haml command [options] file
DESCRIPTION
HAML (HTML Abstraction Markup Language) is a templating language that compiles to HTML. It uses indentation for nesting and provides a concise syntax for HTML elements, attributes, and embedded Ruby.Since Haml 6, the engine is built on Temple and the `haml` executable is a subcommand-based CLI (render, compile, temple, parse, version) rather than a single set of flags.HAML is commonly used in Ruby on Rails applications, via the separate `haml-rails` gem, but can be used standalone for any HTML generation.
PARAMETERS
render file
Render the Haml template and print the resulting HTML to stdout. Use - to read from stdin.compile file
Print the compiled Ruby source for the template instead of evaluating it.-c, --check
With compile, only parse and validate the generated Ruby; print "Syntax OK" or the error instead of the source.temple file
Print the intermediate Temple expression used to generate the Ruby code.parse file
Print the parsed abstract syntax tree.version
Print the installed Haml version.-r, --require file
Require a Ruby library before rendering (render command only).-I, --load-path path
Add a directory to Ruby's load path (render command only).--no-escape-html
Disable automatic escaping of `=` output (escaping is on by default).--no-escape-attrs
Disable automatic escaping of attribute values (escaping is on by default).
HAML SYNTAX
%head
%title My Page
%body
%h1 Hello World
%p.intro Welcome!
#content
%ul
- items.each do |item|
%li= item
INSTALL
CAVEATS
Requires Ruby. Whitespace-sensitive; indentation errors cause failures. The CLI's subcommands (render, compile, temple, parse) replaced the older single-invocation `haml input output` style and flags like `--rails` or `--style` in Haml 6; scripts written for Haml 3/4/5 need updating.
HISTORY
HAML was created by Hampton Catlin in 2006 as part of the Ruby ecosystem. Haml 6 (2022) replaced the original hand-written compiler with one built on Temple, rewrote the CLI around Thor subcommands, and dropped the html4/xhtml output format options.