Simple script to convert ERB files to Haml

A simple script to convert .erb files from current directory to .haml :

#!/usr/bin/ruby
 
Dir.glob("*.html.erb").each do |erbname|
  hamlname = erbname.gsub(".html.erb", ".html.haml")
  system "/usr/bin/html2haml #{erbname} #{hamlname}"
end

2 comments ↓

#1 Sachin singh on 07.08.10 at 9:46 am

i m new to rails please tell me how to use this script, a step by step process.

#2 Vitalie Cherpec on 08.18.10 at 4:17 pm

Copy and paste the script in to a file, then run it within the directory containing *.erb files.

Leave a Comment