Here’s my haml code:
%li.active
%a{ :href => "#" } Home
%li
%a{ :href => "#" } About
%li
%a{ :href => "#" } Sign up
%li
%a{ :href => "#" } Log in
What would be the cleanest way of adding the .active attribute to the element which represents the current page? I’ve thought of passing a string to the template and looping through all the elements, building the menu from a hash, but it seems like there has to be a cleaner way.
Is there a ‘correct’ way of doing this? I have to assume it’s a very common operation.
Thanks
If you don’t have too many navigation items, you could do something like this: