Repository navigation
How To: Create Haml and Slim Views
The Haml/Slim view generators were removed from Devise 1.2 . Here is a tutorial how to create Haml/Slim views with Devise 1.2 or later.
gem install haml hpricot ruby_parser slim haml2slim
rails generate devise:views
for i in `find app/views/devise -name '*.erb'` ; do html2haml -e $i ${i%erb}haml ; rm $i ; done
for i in `find app/views/devise -name '*.haml'` ; do haml2slim $i ${i%haml}slim ; done
for i in `find app/views/devise -name '*.haml'` ; do rm $i ; donegem install haml ruby_parser
rails generate devise:views
for /r app\views\devise %I in (*) do html2haml -e %I %~dpnI.haml
del /f /s /q app\views\devise\*.erbThe Haml-gem obviously needs to be installed.
gem install hamlWith Haml comes a command line tool called ‘html2haml’ which will be used. It has some dependencies which are not installed alongside Haml, so you need to install these next.
gem install hpricot ruby_parserNext you need run the generator to create the devise views.
rails generate devise:viewsIf you have HAML set as default, add the ERB option.
rails generate devise:views -e erbNow convert the erb-files to Haml with the following command.
for i in `find app/views/devise -name '*.erb'` ; do html2haml -e $i ${i%erb}haml ; doneThen, remove erb files from app/views/devise folder.
for i in `find app/views/devise -name '*.erb'` ; do rm $i ; doneOr, in a single step:
for i in `find app/views/devise -name '*.erb'` ; do html2haml -e $i ${i%erb}haml ; rm $i ; doneThe Slim-gem obviously needs to be installed. We use a gem called ‘haml2slim’ to create the Slim-views.
gem install slim
gem install haml2slimAs we need Haml-views to convert them to Slim-views, you need to follow the steps to create the Haml-views described above. Afterwards the views can be converted with the following command.
for i in `find app/views/devise -name '*.haml'` ; do haml2slim $i ${i%haml}slim ; doneThen, remove haml files from app/views/devise folder.
for i in `find app/views/devise -name '*.haml'` ; do rm $i ; done