Module: BootstrapNavHelper

Defined in:
app/helpers/bootstrap_nav_helper.rb

Overview

RAILS BOOTSTRAP ENGINE

Sidebar & Nav: tabs, pills, and lists twitter.github.com/bootstrap/components.html#navs

Copyright 2012-2013 Luiz Eduardo de Oliveira Fonseca, Agência Orangeweb

Licensed under The MIT License

opensource.org/licenses/MIT

Instance Method Summary collapse

Instance Method Details

Separate groups of nav links with a header

<li class=“nav-header”>List header</li>



58
59
60
# File 'app/helpers/bootstrap_nav_helper.rb', line 58

def nav_header title
	(:li, title, :class => "nav-header" )
end

Output a Nav Link

if not in current page

<li><a href=“#”>Link</a></li>

if in current page

<li class=“active”><a href=“#”>Link</a></li>



74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/helpers/bootstrap_nav_helper.rb', line 74

def nav_link(title, link, opts={})
	recognized = Rails.application.routes.recognize_path(link)
	if recognized[:controller] == params[:controller] && recognized[:action] == params[:action]
		(:li, :class => "active") do
			link_to( title, link, opts)
		end
	else
		(:li) do
			link_to( title, link, opts)
		end
	end
end

Bootstrap Nav-list

<ul class=“nav nav-list”> … link itens … </ul>



35
36
37
# File 'app/helpers/bootstrap_nav_helper.rb', line 35

def nav_list &block  
	(:ul, capture(&block), :class => "nav nav-list" )
end

Nav-pills block

<ul class=“nav nav-pills”> … link itens … </ul>



47
48
49
# File 'app/helpers/bootstrap_nav_helper.rb', line 47

def nav_pills &block  
	(:ul, capture(&block), :class => "nav nav-pills" )
end

Sidebar block



23
24
25
# File 'app/helpers/bootstrap_nav_helper.rb', line 23

def sidebar &block 
	(:div, capture(&block), :class => "well sidebar-nav" )
end