09 September 2010

The Ruby Reflector

Topic

link_to

  Source Favicon
By Oleg of Blog | The Working Group 10 months ago.
Email

I have a question for you. How do you deal with the logic of setting links as active in your navs?

Actually, I don't want to know. It's probably awful. I might have a pretty good solution for you. Let's take a look at a very simple nav. These examples all use HAML :

% ul

% li= link to 'Home' , home_path

% li= link_to 'Puppies' , puppies_path

% li= link to 'Kittens' , kittens_path

% li= link to ' Froggies' , froggies_path

blog.twg.ca Read
  Source Favicon
On Be Genius 10 months ago.
Email

… ' http://chendo.net/ ' , = link to ' Ryan Bigg ' , ' http://frozenplague.net/ '

However, we can make this list of people more semantic by using an ul > element and some CSS magic.

Here's what the new HTML ( HAML here) would look like:

1 2 3 4 5 6 7 % footer % aside % ul % li = link to ' Dr Nic Williams ' , ' http://drnicwilliams.com/ ' % li = link to ' Bodaniel Jeanes…

bjeanes.com Read