Skip to content

Instantly share code, notes, and snippets.

@bmarini
Created February 9, 2011 16:36
Show Gist options
  • Save bmarini/818770 to your computer and use it in GitHub Desktop.
Save bmarini/818770 to your computer and use it in GitHub Desktop.
Drop this in lib/tasks/haml.rake and run rake haml:assimilate
namespace :haml do
desc "Convert all .erb views to .haml"
task :assimilate => :environment do
git = File.exist?( Rails.root.join('.git') )
chdir Rails.root do
Dir["app/views/**/*.erb"].map do |file|
[ file, file.gsub(/\.erb$/, '.haml') ]
end.each do |(erb, haml)|
sh "bundle exec html2haml #{erb} #{haml}"
sh "git rm #{erb} && git add #{haml}" if git
end
end
puts "All your erb are belong to us"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment