Switch to HAML
Published: October 6, 2020
This is part of The Annotated Guide to a New Rails App, a list of recommendations to make developing your Rails app more productive and joyful.
In this article, we are talking about switching to HAML.
I recommend switching to HAML before investing significant effort into your HTML.
HAML is an HTML templating language. It makes it easier and more pleasant to write HTML templates.
The default templating language for Rails is ERB (aka eRuby or Embedded Ruby).
It is a simple way to embed Ruby code into text files using expression tags
<%= %>) and execution tags (
HAML is a templating language that makes the HTML structure clear and easy to work with by using meaningful whitespace and eliminating unnecessary characters.
gem 'haml-rails' to your
Gemfile and run
Replace all your ERB
with HAML views by running
HAML_RAILS_DELETE_ERB=true rails haml:erb2haml.