small medium large xlarge

Generic-user-small
08 Sep 2010, 15:14
Joost Saanen (6 posts)

I want to implement the depot application using HAML but I am not be able to parse this partial to HAML in a right way. I keep struggling with idents in the haml file

<% if line_item == @current_item %>
  <tr id="current_item">
<% else %>
  <tr>
<% end %> 

<td>
  <%= line_item.quantity %>&times;</td>
  <td><%= line_item.product.title %></td>
  <td class="item_price"><%= number_to_currency(line_item.total_price) %></td>
</tr>

I the following but that doesn’t work because of the indenting is not right:

- if @current_item == line_item
  %tr{:id => "current_item"}
-else
  %tr

  %td= "#{line_item.quantity} x #{line_item.product.title}"
  %td{:class => "line_item_price"}= number_to_currency(line_item.total_price)
Samr_small_pragsmall
08 Sep 2010, 15:43
Sam Ruby (634 posts)

Try:

%tr{:id => @current_item==line_item && 'current_item'}
  %td= "#{line_item.quantity} x #{line_item.product.title}" 
  %td{:class => "line_item_price"}= number_to_currency(line_item.total_price)
Generic-user-small
08 Sep 2010, 16:17
Joost Saanen (6 posts)

works like a charm! Thx Sam

You must be logged in to comment