Officiel Github Haml-rails Tutoriel HamlTutorial
Gemfile
#Ajoutez ce qui suit`bundle install`
gem "haml-rails", "~> 2.0"
#Pour Rails 4
gem "haml-rails", "~> 1.0.0"
#Pour Rails 3
gem "haml-rails", "~> 0.4.0"
** Convertissez html.erb en html.haml **
$ rails generate haml:application_layout convert
Lors de la conversion de tous les fichiers erb
$ rails haml:erb2haml
erb
<div>blue</div>
<div class="sky">blue</div>
<div class="sky">blue</div>
<div class="sky" id="line">blue</div>
haml
%div blue
%div.sky blue
.sky blue
.sky#line blue
erb
<% if user_signed_in? %>
<%= hoge %>
<% else %>
<%= skyblue %>
<% end %>
haml
- if user_signed_in?
= hoge
- else
= skyblue
erb
<div class="header-nav">
<nav>
<ul class="nav-list">
<% if current_user %>
<li class="list-item"><%= content %></li>
<li class="list-item" id="sky"><%= link_to "blue" %></li>
<% else %>
<li class="list-item"><%= content %></li>
<li class="list-item" id="sky"><%= link_to "blue" %></li>
<% end %>
</ul>
</nav>
</div>
haml
.header-nav
%nav
%ul.nav-list
- if current_user
%li.list-item= content
%li.list-item#sky= link_to "blue"
- else
%li.list-item= content
%li.list-item#sky= link_to "blue"