When comparing Haml vs ERB, the Slant community recommends ERB for most people. In the question“What are the best Ruby templating languages?” ERB is ranked 2nd while Haml is ranked 3rd. The most important reason people chose ERB is:
Since ERB is included with Ruby out of the box, there is no additional installation and setup required. The fact that it's included by default in Ruby, a lot of projects use it.
Ranked in these QuestionsQuestion Ranking
Pros
Pro Easy to learn
There are plenty of learning resources available for those who want to learn Haml. The documentation is detailed and well organized, and Haml is easy to pick up.
Pro Efficient
By using indentation rather than closing tags and eliminating curly braces, Haml is fast to code.
For example
This:
<div id ="lower">
<div class="right column">
<div id="currentDate"><%= print_date %></div>
</div>
</div>
Can be written as:
%div#lower
%div.right.column
%div#currentDate= print_date
Pro Clean syntax
Haml's syntax is very clean and pleasant to look at. It doesn't use HTML tags and it's not verbose at all. The templates are easily readable.
Pro Comes with Ruby
Since ERB is included with Ruby out of the box, there is no additional installation and setup required. The fact that it's included by default in Ruby, a lot of projects use it.
Pro HTML with embedded Ruby
ERB is a way to embed Ruby into plain HTML, which means there is no need to learn a new syntax for HTML. This makes ERB fast to learn, and a great option to use on projects that have multiple developers/designers.
Pro Familiar even for developers with no Ruby experience
ERB's interpolated tags are very familiar to developers who have worked with PHP, ASP or JSP, even though they may not have any prior experience with Ruby.
Pro Maintained by Ruby on Rails developers
Due to Ruby on Rails (RoR) use of ERB, the developers of RoR will continue to maintain ERB, guaranteeing project health.
Pro Best Performance
It has the best performance of all of ruby templates, although it wasn't designed for productivity as HAML or SLIM.
Cons
Con Bad Performance
The rendering time with haml is slower than its competitors.
Con Whitespace sensitivity can be problematic
Haml uses indentation to define structure, rather than closing tags. Though this, in most cases, makes code more efficient to write, it can also cause problems.
Being off by one space can cause an error or change the structure of the code.
Con Verbose
Since ERB uses HTML syntax with Ruby logic inside it can get a little verbose like HTML files usually do.