Skip to content

Instantly share code, notes, and snippets.

@quartzmo
Created January 29, 2014 00:01
Show Gist options
  • Save quartzmo/8679132 to your computer and use it in GitHub Desktop.
Save quartzmo/8679132 to your computer and use it in GitHub Desktop.
haml2erb.herokuapp.com client
require "net/http"
require "uri"
uri = URI.parse("http://haml2erb.herokuapp.com/api.json")
files = Dir.glob("app/views/**/*.html.haml")
files.each do |file|
haml = File.read(file)
response = Net::HTTP.post_form(uri, {"haml" => haml})
erb_file = file.sub(".haml", ".erb")
File.open(erb_file, 'w') do |f|
stripped_body = response.body.gsub(/\A"/,'').gsub(/"\z/,'')
lines = stripped_body.split('\n')
lines.each do |line|
f.puts line
end
puts erb_file
puts ""
puts ""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment