Convert Rails views from html.slim to html.erb

orange plastic blocks on white surface

Install Slim as a gem

gem install slim

Create a shell script in your app/views folder

for file in $(find . -name \*.slim); do
  slimrb -c --rails --erb $file | sed 's/::Temple::Utils\.escape_html((\(.*\))) %>/\1 %>/g'  > $erb_file
  echo $erb_file
find . -name "*.slim" -type f -delete

Unfortunately, you will need to do some manual work – slimrb doesn’t generate properly formatted ERB templates.

Leave a Comment

Your email address will not be published. Required fields are marked *