Skip to content

Instantly share code, notes, and snippets.

@tjh
Created December 29, 2009 04:03
Show Gist options
  • Save tjh/265142 to your computer and use it in GitHub Desktop.
Save tjh/265142 to your computer and use it in GitHub Desktop.
#
# Convert all ERB templates to HAML in app/views/
#
# Notes
# -- Will delete the existing erb templates
# -- This is a tweaked version from http://snippets.dzone.com/posts/show/6838
#
# Usage
# -- Save as 'hamlize.rb' in APP_PATh/script/
# -- Run with 'ruby script/hamlize.rb' in your app root
#
class ToHaml
def initialize(path)
@path = path
end
def convert!
Dir["#{@path}/**/*.erb"].each do |file|
`html2haml -rx #{file} #{file.gsub(/\.erb$/, '.haml')}`
`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