Skip to content

What is HAML?

DeeDeeG edited this page Jan 5, 2018 · 4 revisions

HAML

If you know about HTML and CSS, then HAML should be fairly easy to learn.

Writing HAML is like writing HTML, but with a lot less typing, because HAML is generally set up to be a shorthand for otherwise lengthy HTML markup. HAML is integrated to some extent with the general Ruby community of software development.

from haml.info:

What is it?

Haml (HTML abstraction markup language) is based on one primary principle: markup should be beautiful. It’s not just beauty for beauty’s sake either; Haml accelerates and simplifies template creation down to veritable haiku.

Unspace Interactive and several other professional Rails shops use Haml exclusively for their projects, valuing its focus on cleanliness, readability, and production speed.

Give yourself 5 minutes to read the tutorial and then convert one of your ERB templates to Haml. Simplify. Enjoy. Laugh. 20 minutes later, you will never go back.

Suggested reading: http://haml.info/tutorial.html (This is a very helpful tutorial.)

For more context: https://en.wikipedia.org/wiki/Haml

Full language documentation: http://haml.info/docs/yardoc/file.REFERENCE.html

HAML is designed to replace ERB (eRuby), and can handle embedded Ruby code!

To quote Wikipedia:

eRuby (Embedded Ruby) is a templating system that embeds Ruby into a text document. It is often used to embed Ruby code in an HTML document . . .

HAML also embeds Ruby code, if you want, just like ERB does. In fact, our .haml files have a fair amount of embedded Ruby code. If it doesn't look even slightly like HTML, suffice it to say: It's probably Ruby.

For more info on how Ruby code is used in HAML files, see this from the official documentation: http://haml.info/docs/yardoc/file.REFERENCE.html#ruby-evaluation

Where's the code?

All our .HAML and .ERB files are located here: https://github.com/RefugeRestrooms/refugerestrooms/tree/develop/app/views

Clone this wiki locally