Skip to content

Instantly share code, notes, and snippets.

@jteneycke
Last active October 21, 2016 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jteneycke/4cabb142035fb71d74ce6ef4bb0cf2b1 to your computer and use it in GitHub Desktop.
Save jteneycke/4cabb142035fb71d74ce6ef4bb0cf2b1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "pry"
def command?(name)
`which #{name}`
$?.success?
end
htmls = `find . -type f -name \*.html`.split("\n")
erbs = `find . -type f -name \*.html.erb`.split("\n")
files = htmls + erbs
if command?("html2haml")
puts "yes"
files.each do |file|
new_extension = file.gsub(/(html|html.erb)$/, "haml")
`html2haml #{file} > #{new_extension}`
`rm #{file}`
puts "Converting and removing #{file.split("/").last}"
end
else
puts "No binary for html2haml. Please install it by pasting:"
puts "gem install html2haml"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment