I am attempting to write this html in haml so as to add an id tag if the item is the current one. This is to setup for jquery highlighting.
<% if line_item == @current_item %>
<tr class="line_item id="current_item">
<% else %>
<tr class="line_item">
<% end %>
<td><%= line_item.quantity %>×</td>
<td><%= line_item.product.title %></td>
<td class="item_price"><%= number_to_currency(line_item.total_price) %></td>
</tr>
Because I don't want to write a helper method, I've stuck the if statement within the tag:
%tr.line_item{ :id => (line_item == @current_item ? '' : 'current_item') }
%td
= line_item.quantity
%td
\x #{line_item.product.title}
%td.item_price
= number_to_currency(line_item.total_price)
%td.item_remove
= button_to 'Remove', line_item, :method => :delete
However, this id tag of 'current_item' sticks with all the items and not just the current one. This results in javascript highlighting all or the wrong entry. Thoughts on how to get haml to cooperate?