module SelectedLinks::ActionView

Usage is the same as link_to and takes an optional regex argument matcher.

<%= selectable_link_to 'Home', root_url, :matcher => '\/\z' %>

That would make this link have a class of ‘selected’ when the url is at the top level.

<%= selectable_link_to 'Topics', topics_url, :matcher => 'topic' %>

This will make the nav link selected when the url has ‘topic’ in it anywhere.

<% selectable_link_to community_url, :matcher => 'topic' do %>
  <%= content_tag :span, 'Community', :class => 'foo' %>
<% end %>

Blocks still work and this will do the same thing as the previous example.

<%= selectable_link_to 'ABOUT', about_url %>

Without a matcher option and NOT in the block form, this will look for ‘about’ in the url.

Public Instance Methods