janvier 24, 2013
Template Converters ERB => SLIM

How convert your .erb to .slim :

You must pass through HAML !

Install HAML dependencies on your environment or your gemset

gem install haml # https://github.com/haml/haml
gem install hpricot
gem install ruby_parser

Switch to HAML templating

find . -name '*erb' | \
xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}' | \
bash

Install SLIM tool dependency

gem install haml2slim # https://github.com/fredwu/haml2slim

Switch to SLIM templating

find . -name '*haml' | \
xargs ruby -e 'ARGV.each { |i| puts "haml2slim #{i} #{i.sub(/haml$/,"slim")}"}' | \
bash

Clean ERB and HAML templates

find . -name '*erb' -exec rm -f {} \;
find . -name '*haml' -exec rm -f {} \;

Remove dependencies

gem uninstall haml
gem uninstall hpricot
gem uninstall ruby_parser
gem uninstall haml2slim

That all, have fun

5:23pm  |   URL: http://tmblr.co/ZhYFhxcXXqGo
Classé dans: rails template erb haml slim convert 
blog comments powered by Disqus