Created
April 28, 2014 00:21
-
-
Save lastobelus/11358852 to your computer and use it in GitHub Desktop.
shell functions to convert erb to slim
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
# will skip *.js.erb files | |
function slimify() { | |
# because gem install is slow, particularly if installing nokogiri | |
if gem list html2haml | grep html2haml;then | |
if gem list haml2slim | grep haml2slim; then | |
gem update html2haml haml2slim -N | |
else | |
gem update html2haml -N | |
gem install haml2slim -N | |
fi | |
gem cleanup html2haml haml2slim | |
else | |
if gem list haml2slim | grep haml2slim; then | |
gem install html2haml -N | |
gem update haml2slim -N | |
else | |
gem install html2haml haml2slim -N | |
fi | |
fi | |
find . -name '*erb' ! -name '*.js.erb' | \ | |
xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}' | \ | |
bash | |
find . -name '*haml' | \ | |
xargs ruby -e 'ARGV.each { |i| puts "haml2slim #{i} #{i.sub(/haml$/,"slim")}"}' | \ | |
bash | |
find . -name '*haml' -exec rm {} \; | |
git status | |
echo "run slimifyf to cleanup erb files" | |
} | |
function slimifyf(){ | |
find . -name '*erb' -exec rm {} \; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment