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
linux + ruby on rails = love
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 ↓
i m new to rails please tell me how to use this script, a step by step process.
Copy and paste the script in to a file, then run it within the directory containing *.erb files.
Leave a Comment