Haml is like ERB but way better…
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 'https://rubygems.org' 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:
4. Open up the new file in Sublime like so:
5. Write only the name of the html element – no <> or </> but DO add % in front all elements:
%header %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.