Skip to content

Instantly share code, notes, and snippets.

@blake-simpson
Last active January 6, 2019 22:48
Show Gist options
  • Save blake-simpson/3654276 to your computer and use it in GitHub Desktop.
Save blake-simpson/3654276 to your computer and use it in GitHub Desktop.
Convert all ERB templates to HAML templates

Prerequisites

You must have the following gems installed:

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

Create 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

Thanks to: http://shifteleven.com/articles/2008/06/08/converting-erb-to-haml-snippet

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