Template engines of Ruby
ERb (Ruby STL or erubis or erubi implementation)
Most of the time it is simple, but can get messy if you are doing a lot of database queries and
xxx.each do |x|… It may be better to use partial rendering on collection.
render partial: 'page/show', collection: @pages
And it is the best for playing with code (like the third attempt to implement flexboxes). It is possible to change code or CSS classes and identifiers very fast and messing with indentation like in HAML and Slim is very irritating. One of the disadvantages may be, that syntax hightlighting doesn’t work with editors like Kate or Scribes.
- can be messy
+- PHP like syntax
The next step the Ruby programmer makes, is to notice that ERb is too messy and verbose. And bumps into HAML. I think the manual describes the process of converting to HAML is that you press backspace and delete characters. Because HAML depends on indentation, lines like <% end %> or </div> aren’t necessary.
The disadvatage is, that HAML used to sort attributes (in Ruby 1.8 I think), and you are a bit limited to do more complex structure in the document. Which is fine, but many times irritating (mostly in tags). And it doesn’t properly indent source code by default. I like nice source.
+ has a lot less characters
- debug (sometimes)
- enforces own style of HTML tags
- rendered source code is ugly by default
Slim language [slim-lang.com]
|It is very similar to HAML, but I would say that it provides much more freedom and fun. Well, the main difference is, that lines with text must begin with||, but HTML tags don’t have have
+ more fun and freedom than HAML
+ really, really much more fun