Day 29: What Does HAML Do?

Haml is like ERB but way better…

Tuesday, October 1st

Tuesday, October 1st

Front-end and back-end finally stop frontin’ their feelings for each other and find a way make things work. They owe it all to a little yenta matchmaker named Haml.

Haml told HTML to let his guard down and stop insisting on those annoying closing tags. Then Haml had it out with Rails. She was like, “ERB isn’t all that. I’m way more relaxed but we only party with proper tabbing.”

Okay, never mind. This post went downhill fast. It’s 3am and Amy and I have been at school since 9am yesterday so here’s what I really learned on this day:

1. In your Rails Gemfile, add the haml gem:

source '' 
gem 'haml'

2. Save the file. Go to Terminal. CD to your local copy of that Rails app. Type into Terminal:


3. Now haml is ready to go. So create a new file in Terminal that ends with .html.haml:

touch newfile.html.haml

4. Open up the new file in Sublime like so:

 subl newfile.html.haml

5. Write only the name of the html element – no <> or </> but DO add % in front all elements:

 %h1 H
 %h1 A
 %h1 M
 %h1 L
Check it out! no closing anything!

*Adding your Ruby bits will be a bit more work BUT still better than ERB because you don’t need <%= blah blah %>.

The end. Good night.

what are your thoughts?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s