Module: BootstrapBreadcrumbsHelper

Defined in:
app/helpers/bootstrap_breadcrumbs_helper.rb

Overview

RAILS BOOTSTRAP ENGINE

Breadcrumbs twitter.github.com/bootstrap/components.html#breadcrumbs

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

Generates a Breadcrumb Containner

<ul class=“breadcrumb”> <li><a href=“#”>Home</a> <span class=“divider”>/</span></li> <li><a href=“#”>Library</a> <span class=“divider”>/</span></li> <li class=“active”>Data</li> </ul>



28
29
30
# File 'app/helpers/bootstrap_breadcrumbs_helper.rb', line 28

def breadcrumb &block  
	(:ul, capture(&block), :class => "breadcrumb" )
end

Generate a Breadcrumb Active link markup

<li class=“active”>Data</li>



75
76
77
78
# File 'app/helpers/bootstrap_breadcrumbs_helper.rb', line 75

def breadcrumb_active(title)
	content_for :page_title do title end
	 :li, title, :class => "active"
end

Generate a breadcrumb divider markup

<span class=“divider”>/</span>



91
92
93
# File 'app/helpers/bootstrap_breadcrumbs_helper.rb', line 91

def breadcrumb_divider(text = "/")
  	(:span, text, :class => "divider")
end

Generate a Breadcrumb link markup

if not in current page

<li><a href=“#”>Home</a> <span class=“divider”>/</span></li>

if in current page

<li class=“active”>Data</li>



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/helpers/bootstrap_breadcrumbs_helper.rb', line 48

def breadcrumb_item(title, link, opts={})

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