I have a requirement to make a app that has a view. In that view I need to check a condition and if it is true, then need to color a table row appropriately. The easiest way to do this is just to use different header in the view. But how to do it if I want to keep all my styling information in CSS?
2 Answers
If it's just a row you want to colour then you can do it in the view, no need to mess around with headers:
<tr class="<%= "blue" if some_condition %>">
<td>Your text</td>
</tr>
Or:
<% if some_condition %>
<tr class="blue">
<% else %>
<tr class="red">
<% end %>
<td>Your text</td>
</tr>
1 Comment
Kert
Thanks! I just forgot about classes :P