-
Notifications
You must be signed in to change notification settings - Fork 13
Navigations
David Van Der Beek edited this page Jul 24, 2014
·
6 revisions
Leather has a helper method that lets you generate Bootstrap navbars and navigation lists. For example, you can render a navbar with the following code:
= navbar "Leather", root_url, container_mode: :with, class: "navbar-inverse" do
= nav_list do
= dropdown_nav_item 'Lorem', '#' do
= nav_item 'Ipsum', '#'
= nav_item 'Dolor', '#'
= nav_item 'Sit', '#'
= nav_item 'Home', '#'
= nav_item 'Dolor', '#'
= nav_item 'Sit', '#'
= nav_list class: 'navbar-right' do
- if user_signed_in?
= nav_item 'Sign Out', destroy_user_session_path, method: :delete
- else
= nav_item 'Sign In', new_user_session_path
= nav_item 'Sign Up', new_user_registration_path`
With a little extra setup, you can manage the "active" nav_item easily. First, in your controller, add this:
set_tab :name, :namespace
This takes the same options as a before_filter, so you can restrict it to certain actions:
set_tab :name, :namespace, only: [:index, :show]
When you generate a nav_item or a dropdown_nav_item, you can identify the link's name and namespace:
= nav_item 'Home', '#', nav_id: [:name, :namespace]