Git Product home page Git Product logo

breadcrumbs's Introduction

Setting up breadcrumbs

Adding single breadcrumb:

<% breadcrumbs ["My page", page_url] %>

End-point breadcrumb (won't generate a link):

<% breadcrumb "Current page" %>

Adding multiple breadcrumbs:

<% breadcrumbs << ["My page", page_url] << ["Other page", other_page_path] %>

Prepending breadcrumbs

<% breadcrumbs >> ["This will be first", root_url]%>

Generating breadcrumbs with a block:

<%
  breadcrumbs do |b|
    b << ["My page", page_url] if some_condition?
    b << "Current page"
  end
%>

Breadcrumbs for objects (using helpers):

<% breadcrumbs_for @page %> # Will call page_breadcrumbs(@page) helper to receive breadcrumb options

<%
  breadcrumbs do |b|
    b.breadcrumbs_for(:root, @page) # will call root_page_breadcrumbs(@page)
  end
%>

Generating HTML output

Generate using default HTML markup^

<%= breadcrumbs.to_html %>

Customize HTML markup (all blocks are optional):

<% breadcrumbs.to_html do |b| %>
  <% b.separator do %> &raquo;&raquo;&raquo; <% end %>

  <% b.item do |item, index, items| %>
    <%= index %> of <%= items.size %>: <%= item.inspect %>
  <% end %>

  <% b.current do |item, index, items| %>
    <em>Last: <%= item.inspect %></em>
  <% end %>

  <% b.wrap do |result| %>
    <blockquote><%= result %></blockquote>
  <% end %>
<% end %>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.