Skip to content

Instantly share code, notes, and snippets.

@wegorich
Created April 27, 2013 11:35
Show Gist options
  • Save wegorich/5472790 to your computer and use it in GitHub Desktop.
Save wegorich/5472790 to your computer and use it in GitHub Desktop.
erb2haml.rake (put to lib/task/ forder) gems required gem 'haml-rails' gem 'html2haml' gem 'hpricot' gem 'ruby_parser'
namespace :erb do
namespace :to do
desc 'Converts all .html.erb files to .html.haml'
task :haml do
print "looking for erb views..\n"
files = `find ./app/views -name *.html.erb`
files.each_line do |file|
file.strip!
print "parsing file: #{file}\n"
`bundle exec html2haml #{file} | cat > #{file.gsub(/\.erb$/, ".haml")}`
`rm #{file}`
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment