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

slim2erb.sh

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

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.