Skip to content

Instantly share code, notes, and snippets.

@JangoSteve
Created November 14, 2011 06:14
Show Gist options
  • Save JangoSteve/1363366 to your computer and use it in GitHub Desktop.
Save JangoSteve/1363366 to your computer and use it in GitHub Desktop.
Converting all ERb views to Haml, modified from http://snippets.dzone.com/posts/show/5449
require 'hpricot'
require 'ruby_parser'
class ToHaml
def initialize(path)
@path = path
end
def convert!
Dir["#{@path}/**/*.erb"].each do |file|
new_file = file.gsub(/\.erb$/, '.haml')
`html2haml -rx #{file} #{new_file}`
`rm #{file}`
end
end
end
path = File.join(File.dirname(__FILE__), 'app', 'views')
ToHaml.new(path).convert!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment