Created
July 4, 2012 20:55
-
-
Save dpaluy/3049495 to your computer and use it in GitHub Desktop.
Convert Erb to Haml
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
| class ToHaml | |
| def initialize(path) | |
| @path = path | |
| end | |
| def convert! | |
| Dir["#{@path}/**/*.erb"].each do |file| | |
| `html2haml -rx #{file} #{file.gsub(/\.erb$/, '.haml')}` | |
| end | |
| end | |
| end | |
| path = File.join(File.dirname(__FILE__), 'app', 'views') | |
| ToHaml.new(path).convert! |
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
| namespace :erb do | |
| namespace :to do | |
| desc "Converts all .html.erb files to .html.haml" | |
| task :haml do | |
| puts "looking for erb views..." | |
| files = `find ./app/views -name *.html.erb` | |
| files.each_line do |file| | |
| file.strip! | |
| puts "parsing file: #{file}" | |
| `bundle exec html2haml #{file} | cat > #{file.gsub(/\.erb$/, ".haml")}` | |
| `rm #{file}` | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment