Skip to content

Instantly share code, notes, and snippets.

@mokolabs
Created February 24, 2011 00:06
Show Gist options
  • Save mokolabs/841484 to your computer and use it in GitHub Desktop.
Save mokolabs/841484 to your computer and use it in GitHub Desktop.
# Simple batch convertor for ERB => HAML
# To run, move to app root and do 'ruby haml.rb'
class ToHaml
def initialize(path)
@path = path
end
def convert!
Dir["#{@path}/**/*.erb"].each do |file|
# puts "html2haml -rx #{file} #{file.gsub(/\.erb$/, '.haml')}"
`html2haml -rx #{file} #{file.gsub(/\.erb$/, '.haml')}`
# puts "mv #{file.gsub(/\.erb$/, '.haml')} #{file.gsub('backup', 'views').gsub(/\.erb$/, '.haml')}"
`mv #{file.gsub(/\.erb$/, '.haml')} #{file.gsub('backup', 'views').gsub(/\.erb$/, '.haml')}`
end
end
end
path = File.join(File.dirname(__FILE__), 'app', 'backup')
ToHaml.new(path).convert!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment