Skip to content

Instantly share code, notes, and snippets.

@rugginoso
Created December 3, 2012 19:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rugginoso/4197512 to your computer and use it in GitHub Desktop.
Save rugginoso/4197512 to your computer and use it in GitHub Desktop.
Helper which marks the current page as 'active' in bootstrap navbar
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Title</a>
<div class="nav-collapse collapse">
<ul class="nav pull-right">
<%= nav_entry 'Home', home_path %>
<%= nav_entry 'About', about_path %>
</ul>
</div>
</div>
</div>
</div>
module ApplicationHelper
def nav_entry(body, path)
content_tag(:li, link_to(body, path), class: ('active' if current_page?(path)))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment