Skip to content

Instantly share code, notes, and snippets.

@mtanzi
Created June 6, 2013 23:54
Show Gist options
  • Save mtanzi/5726020 to your computer and use it in GitHub Desktop.
Save mtanzi/5726020 to your computer and use it in GitHub Desktop.
Script that use herbalizer (https://github.com/danchoi/herbalizer) to convert the haml file present in the views directory into erb.
Dir["#{Rails.root}/app/views/**/*.haml"].each do |file|
file_name = file.split("/").pop
file_dir = file.split("/")[0..-2]
value = %x(~/herbalizer #{file})
new_file = File.join(file_dir, file_name.gsub("haml", "erb"))
File.open(new_file, 'w') do |f|
f.write(value)
end
new_read = File.new(new_file, "r")
if new_read.gets.match(/\A\(line/)
FileUtils.rm(new_file)
else
FileUtils.rm(file)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment