Ruby on Rails - Make Slim the Default Template

Ziyan Junaideen picture Ziyan Junaideen · May 9, 2013 · Viewed 13.9k times · Source

I am working on a Ruby on Rails project and am needing to customize default views provided by Gems.

The requirement is to use Slim for template. I understand that ERB is the default template engine for Rails.

As per my observation, the priority is for ERB and if not it will use Slim/Haml views.

I am interested in knowing if it is possible to set Slim as the default instead of the ERB?

How can this be achieved so that when I create a local version of a template in Slim it will override the template provided by the gem.

Any clue will be appreciated.

Answer

Billy Chan picture Billy Chan · May 9, 2013

You can use "slim-rails" gem which is built for generating slim template as default.

https://github.com/slim-template/slim-rails

Just replace gem 'slim' by gem 'slim-rails' in your Gemfile.