This Ruby script automates several tasks related to managing dependencies and converting ERB templates to Slim templates within a Rails application.

Firstly, it defines a method do_bundle which ensures that dependencies are installed using Bundler.with_unbundled_env before executing bundle install.
Rails application

The script then announces the commencement of applying Slim templating, appending the slim-rails gem to the Gemfile, and injecting html2slim-ruby3 gem within the development group, alongside a descriptive comment. Following this, it executes the do_bundle method to install dependencies.

Next, it employs conversion commands (erb2slim) to transform layout files (application.html.erb, mailer.html.erb, and mailer.text.erb) into Slim templates, all while utilizing the -d flag to indicate a dry run. Additionally, it runs RuboCop with autocorrection enabled (-AS) to ensure code quality.
Finally, it outputs a message confirming the successful switch to Slim templating.
Store above file in your local system as ruby file and You can use this template while creating new application as below

rails new blog -m ~/slim_template.rb

Support On Demand!

Ruby on Rails