-
Notifications
You must be signed in to change notification settings - Fork 5.5k
How To: Create Haml and Slim Views
sj26 edited this page Mar 17, 2013
·
8 revisions
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.
rails generate devise:views
gem install html2haml
for file in app/views/devise/**/*.erb; do html2haml -e $file ${file%erb}haml && rm $file; done
gem install haml2slim
for file in app/views/devise/**/*.haml; do haml2slim $file ${file%haml}slim && rm $file; done
rails generate devise:views
gem install html2haml
for /r app\views\devise %I in (*) do html2haml -e %I %~dpnI.haml
del /f /s /q app\views\devise\*.erb
gem install haml2slim
for /r app\views\devise %I in (*) do haml2slim %I %~dpnI.slim
del /f /s /q app\views\devise\*.haml
First you need run the generator to create the devise ERB files.
rails generate devise:views
Now we need a tool called 'html2haml' which was formely a part of the 'haml' gem but is now separate.
gem install html2haml
Now for each erb file, convert it to Haml and removing the erb if successful.
for file in app/views/devise/**/*.erb; do html2haml -e $file ${file%erb}haml && rm $file; done
We use a gem called 'haml2slim' to create the Slim-views.
gem install haml2slim
As 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. Again, the each Haml file will be removed as a Slim file is successfully generated.
for file in app/views/devise/**/*.haml; do haml2slim $file ${file%haml}slim && rm $file; done