Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

1 total

Convert all erb's to haml's in rails

#!/usr/bin/env ruby
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(ARGV[0])
ToHaml.new(path).convert!


run the file with "ruby hamlit directory"
e.g. ruby hamlit app/views

Warning, this will trash your .erb files, if for some reason you want them hanging around.
1 total