Created
June 6, 2013 23:54
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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