Possible Duplicate:
Append class if condition is true in Haml (with Rails)
I'm using a template that allows you to mark a list item as current
(using class=current
), highlighting it in a nav bar.
In HAML, this looks like:
%li.current
Menu item A
%li
Menu item B
%li
Menu item C
I have this code in a Sinatra view and want to programmatically add the class=current
, depending on a parameter to the view.
How do I do this in the neatest way possible?
Currently, I'm doing it like this:
- if section == "pages"
%li.current
%a{:href => "#pages"} Pages
- else
%li
%a{:href => "#pages"} Pages
Which feels too verbose.