Created
September 9, 2009 14:57
-
-
Save glennr/183776 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#A little script to convert all your .erb views to .haml using html2haml, which is included with Haml installation. | |
#Just drop this in your rails root folder and run it. | |
# | |
# Original Author: http://snippets.dzone.com/posts/show/5449 | |
# | |
# GlennR: 2009 09 09 - Improved output. (I didnt have hpricot installing and the script wasnt telling me otherwise!) | |
# | |
class ToHaml | |
def initialize(path) | |
@path = path | |
end | |
def convert! | |
Dir["#{@path}/**/*.erb"].each do |file| | |
puts "Converting file #{file} to haml..." | |
puts " Running command: html2haml -rx #{file} #{file.gsub(/\.erb$/, '.haml')}" | |
output = `html2haml -rx #{file} #{file.gsub(/\.erb$/, '.haml')}` | |
puts "#{output}" | |
end | |
puts "Done!" | |
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