Over a million developers have joined DZone.

Convert All ERb Views To Haml

·
A little script to convert all your .erb views to .haml using html2haml, which is included with Haml installation.
Just drop this in your rails root folder and run it. (Stolen as a direct copy from http://snippets.dzone.com/posts/show/5449)


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!

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}