Skip navigation

Active Product Development

1 Post tagged with the erb tag


Posted by JeremyGThomas Jun 5, 2012

Three of the products I run technology for are built in Ruby on Rails.  Two of those projects use HAML as the view templating language, while the third is in ERB.  In an informal effort to explore the pros and cons of each to determine if standardization across teams was necessary I ignited a religious war.  Some are passionately pro-HAML, while others are passionately pro-ERB.  Today, in order to be more objective about things, I held a meeting with all of the Ruby developers to compare the two.  Here's what we came up with:



And here's a translation (black - "pro", red - "con")


Faster CodingClose to HTML
Close to CSS Syntax (+1)Generally Understood
Forced FormattingStandard (+1)
Scanability (+3)ERB is applicable to all view files (via extension)
Value given to Whitespace (+2)Overly Verbose
Value given to Whitespace (yes, someone argued this as a positive)HTML is Error Prone (i.e. missing closing tags)
Tendency to Over Use DivsCloser to what the Browser Sees
Less CodeCloser to other languages (+1)
Learning Curve (+1)
Ruby Conditional Statements cannot be Intermixed withing JS blocks
Not standard and likely won't be
Forces succint Views
Follows the spirit of Ruby (beautiful code)
Looks like Perl with Excessive Symbols
"Shells" out to other languages


Given this list, we had a healthy debate about the value of each templating language.  In the end we decided the differences between the two weren't great enough to refactor our code in the name of standardization.  But we did decide to use ERB as the default, namely because of its proximity to other languages (i.e. PHP) and the correlating low ramp up time when training new developers in Ruby on Rails (including HTML/CSS developers).  So, with any new project we initiate in Rails there has to be a good reason not to use ERB, and a discussion will ensue to make a decision about which is best for said project.

4,558 Views 0 Comments Permalink Tags: ruby, ruby_on_rails, erb, haml