Skip to content

Instantly share code, notes, and snippets.

@kstevens715
Created May 16, 2012 00:47
Show Gist options
  • Save kstevens715/2706367 to your computer and use it in GitHub Desktop.
Save kstevens715/2706367 to your computer and use it in GitHub Desktop.
Generates Twitter Bootstrap compatible breadcrumbs with the Crummy gem.
<% render_crumbs do |crumbs| %>
<ul class="breadcrumb">
<% crumbs.each_with_index do |crumb, index| %>
<li>
<% if index < crumbs.size - 1 %>
<%= link_to *crumb %>
<span class="divider">/</span>
<% else %>
<li class="active"><%= crumb[0] %></li>
<% end %>
</li>
<% end %>
</ul>
<% end %>
@ffscalco
Copy link

Hi, I changed the li's positions...

<% render_crumbs do |crumbs| %>

    <% crumbs.each_with_index do |crumb, index| %> <% if index < crumbs.size - 1 %>
  • <%= link_to *crumb %> /
  • <% else %>
  • <%= crumb[0] %>
  • <% end %> <% end %>
<% end %>

@ffscalco
Copy link

Sorry..

<% render_crumbs do |crumbs| %>
  <ul class="breadcrumb">
  <% crumbs.each_with_index do |crumb, index| %>
    <% if index < crumbs.size - 1 %>
      <li>
        <%= link_to *crumb %>
        <span class="divider">/</span>
      </li>
    <% else %>
      <li class="active"><%= crumb[0] %></li>
    <% end %>
  <% end %>
  </ul>
<% end %>

@philfreo
Copy link

You can just do this instead of making a custom template:

<%= render_crumbs :last_crumb_linked => false, :format => :html_list, :ul_class => 'breadcrumb', :last_class => 'active' %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment