When comparing Haml vs Liquid, the Slant community recommends Haml for most people. In the question“What are the best Ruby templating languages?” Haml is ranked 3rd while Liquid is ranked 4th. The most important reason people chose Haml is:
There are plenty of learning resources available for those who want to learn Haml. The [documentation](http://haml.info/docs/yardoc/file.REFERENCE.html) is detailed and well organized, and Haml is easy to pick up.
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 Clear distinction between presentation and application
Liquid allows developers to create a clear distinction between the presentation and application layer.
Pro Secure
Liquid templates are secure out of the box. They can be used for applications where users can edit the appearance without allowing them to run any server-side code. Liquid does just that without any needed configuration.
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 Boolean algebra has some issues
Liquid has some known issues with boolean algebra when it comes to some advanced expressions.
Liquid::Template.parse("{% if false and false or true %} foo {% endif %}").render
# => ""
false and false or true
# => true
It seems that Liquid simply parses from left to right, and if it finds a false and X
it immediately returns false.
Alternative Products
