Skip to content

Instantly share code, notes, and snippets.

@davemo
Created January 30, 2019 13:08
Show Gist options
  • Save davemo/164ca9bd95a6faf7c15a133476714efd to your computer and use it in GitHub Desktop.
Save davemo/164ca9bd95a6faf7c15a133476714efd to your computer and use it in GitHub Desktop.
Convert HAML to ERB across a folder on Mac OS

steps

  1. install herbalizer somewhere on your PATH, i put mine in ~/bin

cd ~/bin && wget http://openmbta.org/herbalizer && chmod +x herbalizer

  1. do a dry run to see if your renames look ok

find . -name '*haml' | xargs ruby -e 'ARGV.each { |i| puts "herbalizer < #{i} > #{i}.erb" }'

  1. if you're happy, pipe it to bash

find . -name '*haml' | xargs ruby -e 'ARGV.each { |i| puts "herbalizer < #{i} > #{i}.erb" }' | bash

  1. use rename to get rid of the .haml part of the filename

brew install rename if you dont have it

do a dry run with find . -name "*erb" | xargs rename -n -e 's/.haml//' ARGV

if it looks good, do it for real by removing -n find . -name "*erb" | xargs rename -e 's/.haml//' ARGV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment