Description #
HAML (HTML Abstraction Markup Language) is a templating language designed to simplify and clean up HTML syntax. It eliminates repetitive tags and uses indentation to express structure, making markup easier to read and maintain.
History #
HAML was created by Hampton Catlin in 2006 as a response to the verbosity of HTML. It became popular in the Ruby on Rails ecosystem for building clean views quickly. Over the years, HAML has been adopted in various projects that emphasize elegant, readable code, especially in front-end and full-stack Ruby environments.
Hello World Code #
%html
%head
%title Hello, World!
%body
%h1 Hello, World!
How to Run #
HAML is typically compiled into HTML via:
- Ruby Gem: Install HAML via Ruby’s package manager and run
haml input.haml output.html
- Online Compilers:
Key Concepts #
- Indentation-based syntax
- No closing tags
%
for HTML tags.
for classes,#
for IDs- Ruby code embedding with
=
- Clean output HTML
- Rails view integration
- DRY markup
- Partial templates
- YAML-style readability
Try It Online #
Fun Facts #
- HAML’s creator also invented Sass, which shares similar whitespace and readability principles.
- HAML templates often resemble Python’s indentation-based syntax, which improves readability for many developers.
- It inspired similar templating languages like Slim and Jade (now Pug).