Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

erb, haml or slim: which one do you suggest? And why? [closed]

I am learning Rails and I have seen these template engines. I have no experience with them (only erb).

But as I am a beginner, I am really confused. Which one do you suggest and why? Erb, Haml or Slim? Please tell your reason for preferring one over the others. And if you have any other recommendations, please let us know.

EDIT: I am NOT looking for a winner here. I just want to hear your opinions about them, their syntax, speed of execution, and so on.

like image 829
Omid Kamangar Avatar asked Jul 09 '12 07:07

Omid Kamangar


People also ask

Should I use HAML or ERB?

ERB has a simple syntax for mixing HTML and Ruby commands, but it can be somewhat verbose. Haml is a very popular alternative which has a condensed syntax for expressing HTML.

What is a HAML file?

Haml (HTML Abstraction Markup Language) is a templating system that is designed to avoid writing inline code in a web document and make the HTML cleaner.

What is ERB template?

An ERB template looks like a plain-text document interspersed with tags containing Ruby code. When evaluated, this tagged code can modify text in the template. Puppet passes data to templates via special objects and variables, which you can use in the tagged Ruby code to control the templates' output.


1 Answers

Two big advantages of using slim over haml:

  1. Slim is currently about eight times faster than haml.

  2. Slim supports HTTP streaming, while HAML doesn't.

  3. Slim has a more natural syntax: a href="foo.html"

like image 173
Bart ten Brinke Avatar answered Sep 25 '22 01:09

Bart ten Brinke