Created
November 14, 2011 06:14
-
-
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
This file contains hidden or 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
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