Convert ERB views to HAML

Tagged with Ruby haml Rails erb

Language: Ruby

Convert your ERB views to HAML with this simple ruby script. Originally found at http://snippets.dzone.com/posts/show/6838

View as text

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!
Last updated at 18:17 PM on May 05, 2009 by Brian Hogan

SnippetStash costs money to host and develop. The service is free for everyone to use
but if you found it useful please consider making a small donation.