forked from seyhunak/twitter-bootstrap-rails
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Adds twitter bootstrap breadcrumb support.
- Loading branch information
Showing
4 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module TwitterBreadcrumbsHelper | ||
def render_breadcrumbs(divider) | ||
render partial: 'twitter-bootstrap/breadcrumbs', locals: {divider: divider} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<ul class="breadcrumb"> | ||
<% separator = "/"; separator ||= divider %> | ||
<% if @breadcrumbs %> | ||
<% @breadcrumbs[0..-2].each do |crumb| %> | ||
<li> | ||
<a href="<%= crumb[:url] %>"><%= crumb[:name] %></a> | ||
<span class="divider"><%= separator %></span> | ||
</li> | ||
<% end %> | ||
<li class="active"> | ||
<a href="<%= @breadcrumbs.last[:url] %>"><%= @breadcrumbs.last[:name] %></a> | ||
</li> | ||
<% end %> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
lib/twitter/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Twitter | ||
module Bootstrap | ||
module BreadCrumbs | ||
def self.included(base) | ||
base.extend(ClassMethods) | ||
end | ||
|
||
module ClassMethods | ||
def add_breadcrumb name, url, options={} | ||
before_filter options do |controller| | ||
controller.send :add_breadcrumb, name, url | ||
end | ||
end | ||
end | ||
|
||
protected | ||
|
||
def add_breadcrumb name, url = '' | ||
@breadcrumbs ||= [] | ||
url = eval(url) if url =~ /_path|_url|@/ | ||
@breadcrumbs << {name: name, url: url} | ||
end | ||
end | ||
end | ||
end |