Switch to HAML

Damien Burke
1 min readOct 6, 2020

--

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.

When

I recommend switching to HAML before investing significant effort into your HTML.

What

HAML is an HTML templating language. It makes it easier and more pleasant to write HTML templates.

Why

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.

How

Add gem 'haml-rails' to your Gemfile and run bundle.

Replace all your ERB views with HAML views by running HAML_RAILS_DELETE_ERB=true rails haml:erb2haml.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Damien Burke
Damien Burke

Written by Damien Burke

Engineering leader with twenty years of experience in software startups

No responses yet

Write a response