Skip to content

Instantly share code, notes, and snippets.

@phuesler
Forked from stigi/erb2haml.sh
Created September 30, 2012 14:23
Show Gist options
  • Save phuesler/3806885 to your computer and use it in GitHub Desktop.
Save phuesler/3806885 to your computer and use it in GitHub Desktop.
erb2haml.sh
#! /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