-
-
Save phuesler/3806885 to your computer and use it in GitHub Desktop.
erb2haml.sh
This file contains hidden or 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
#! /usr/bin/env sh | |
DEPS_MISSING=0 | |
check_gem() { | |
if ! gem list -i $1 >/dev/null; then | |
echo "Please install $1 with 'gem install $1'" | |
DEPS_MISSING=1 | |
fi | |
} | |
convert() { | |
printf "Starting conversion\n[" | |
for erb_file in `find . -name '*.erb'` | |
do | |
printf "." | |
html2haml -r $erb_file `ruby -e "puts '$erb_file'.sub(/erb$/,'haml')"` | |
rm $erb_file | |
done | |
printf "]\nDone.\n" | |
} | |
check_gem haml | |
check_gem hpricot | |
check_gem ruby_parser | |
if [ $DEPS_MISSING = 0 ];then | |
convert | |
exit 0 | |
else | |
echo "To use $0 you need to have the following gems installed: haml, hpricot and ruby_parser" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment