Just Use ERB
Learn how to use ERB in a Rails application.
We'll cover the following
Templating mechanism in Rails
The default templating mechanism in Rails is HTML using ERB (which we will refer to simply as ERB even though ERB is a general templating system that can template anything). Some developers strongly believe ERB to be problematic and seek to use alternatives like HAML or Slim. We don’t believe the benefits ascribed to these technologies outweigh the downsides, and we want to talk briefly about why. There are two reasons we believe ERB is the sustainable choice:
It’s the default in Rails, so its behavior is managed and updated with Rails and thus more stable and reliable.
It is based on HTML, which is widely understood by almost every web developer, even those unfamiliar with Rails.
Sticking with Rails’ default choices is a sustainable decision because we’ll need to update our version of Rails over the life of the app. The fewer dependencies our app has, the easier that process is going to be. We’re sure HAML and Slim are well-updated and maintained, but incompatibilities might arise with Rails. Rails will not delay a release because of such incompatibilities, but ERB’s incompatibilities will be addressed before every release. This means that HAML and Slim (like any dependency) can prevent us from updating to the latest version of Rails.
Get hands-on with 1200+ tech skills courses.