Skip to content

Instantly share code, notes, and snippets.

@edelpero
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edelpero/8916250 to your computer and use it in GitHub Desktop.
Save edelpero/8916250 to your computer and use it in GitHub Desktop.
Convert all ERB templates to HAML

###1. Prerequisites:

You must have the following gems installed:

  • haml (or haml-rails)
  • hpricot
  • ruby_parser

###2. Create new HAML files

Test the changes: (no files created)

find . -name '*erb' | xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}'

Perform the changes:

find . -name '*erb' | xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}' | bash

###3. Remove the ERB files Delete all files with ERB extensions: find . -name '*erb' | xargs rm -rf ARGV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment