haml / html2haml

Convert HTML and HTML+Erb to Haml.
MIT License
259 stars 55 forks source link

The basic CLI tool doesn't have a way to actually change the file #68

Open olleicua opened 8 years ago

olleicua commented 8 years ago

I made one for myself but it seems like maybe there should be a flag for it.

$ cat ~/bin/ham
#!/usr/bin/env ruby

if ARGV.size != 1 or !(ARGV[0] =~ /.html.erb$/)
  puts "Usage: ham FILE.html.erb"
  exit
else
  old = ARGV[0]
  new = old.sub /\.html\.erb$/, ".html.haml"
  puts "#{old} -> #{new}"
  command = "html2haml #{old} > #{new} && rm -v #{old}"
  exec command
end
$ ham path/to/template.html.erb
path/to/template.html.erb -> path/to/template.html.haml
removed 'path/to/template.html.erb'