Linkety
Linkety is a collection of handy link helpers for Rails views. Helpers include
current_link_to, active_link_to_if, and inactive_link_to_if.
Installation
Add this line to your application's Gemfile:
gem 'linkety'
And then execute:
$ bundle
Or install it yourself as:
$ gem install linkety
Usage
Sometimes you want to add a specific class to a link if you are currently on the
page the link points to. Navigation menus are a classic example of this scenario.
Simply use the current_link_to like so:
<ul class="main-menu">
<li><%= current_link_to "Home", home_url %></li>
</ul>When you are on the home page, this helper with output a link with a current
class. You can change the default class name by defining a :current_class option.
If you want match the current URL against a custom regex instead of an exact path match,
simply pass in a regex object for the :pattern option.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request