百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

crummy

> 编程语言
开源

美味的面包碎片! Crummy 是将面包碎片添加到 Rails 应用程序中的一个简单而美味的方法。

353 stars0 点赞4 次浏览
访问官网GitHub

工具介绍

美味的面包碎片! Crummy 是将面包碎片添加到 Rails 应用程序中的一个简单而美味的方法。

Warning This is no longer maintained and hasn't been for quite some time. I no longer spend any time in the Ruby world. If you would like to maintain it, do reach out and ask.

Crummy

Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.

Install

Simply add the dependency to your Gemfile:

ruby
gem "crummy", "~> 1.8.0"

Example

In your controllers you may add_crumb either like a before_filter or within a method (It is also available to views).

ruby
class ApplicationController
  add_crumb "Home", '/'
end

class BusinessController 

Html options for breadcrumb link

You can set the html options with link_html_options. These are added to the a tag.

ruby
add_crumb "Home", '/', link_html_options: {title: "my link title"}

##You can set html instead text in first parameter. If tag a present in this html, tag a not be a wrapper.

ruby
add_crumb "Support".html_safe, "", {}

Options for render_crumbs

render_crumbs renders the list of crumbs as either html or xml

The output format. Can either be :xml or :html or :html_list. Defaults to :html

ruby
format: (:html|:html_list|:xml)

The separator text. It does not assume you want spaces on either side so you must specify. Defaults to &raquo; for :html and `` for :xml

ruby
separator: string

Render links in the output. Defaults to true

ruby
links: false

Render Richsnipet Default to false

ruby
microdata: true

Optionally disable linking of the last crumb, Defaults to true

ruby
last_crumb_linked: false

With this option, output will be blank if there are no breadcrumbs.

ruby
skip_if_blank: true

Examples

…

A crumb with a nil argument for the link will output an unlinked crumb.

With format: :html_list you can specify additional params: :li_class, :ol_class, :ol_id

App-wide configuration

You have the option to pre-configure any of the Crummy options in an application-wide configuration. The options above are available to configure, with the exception of :separator, as well as many others.

The biggest difference is that :separator is not an option. Instead, you have format-specific configuration options: :html_separator, :xml_separator, and :html_list_separator. :separator can still be overridden in the view.

Insert the following in a file named config/initializers/crummy.rb:

ruby
Crummy.configure do |config|
  config.format = :xml
end

Possible parameters for configuration are:

ruby
:format
:links
:skip_if_blank
:html_separator
:xml_separator
:html_list_separator
:html_list_right_separator
:first_class
:last_class
:ol_id
:ol_class
:li_class
:li_right_class
:microdata
:last_crumb_linked
:truncate
:right_side

See lib/crummy.rb for a list of these parameters and their defaults.

###Individually for each crumb configuration:

ruby
add_crumb support_link, {:right_side => true, :links => "/support", : li_class => "my_class", :li_right_class => "pull-right hidden-phone"}

Simple add that parameter to options hash.

Live example application

An example application is available right inside this gem. That application is documented, see example/README for details about usage.

Todo

  • Accept collections of models as a single argument
  • Accept instances of models as a single argument
  • Allow for variables in names. (The workaround is to do your own before_filter for that currently)
  • Make a crumbs? type method

Credits

  • Zach Inglis of Superhero Studios
  • Andrew Nesbitt
  • Rein Henrichs
  • Les Hill
  • Sandro Turriate
  • Przemysław Kowalczyk
    • feature ideas
  • Sharad Jain
  • Max Riveiro
  • Kamil K. Lemański
  • Brian Cobb
  • Kir Shatrov (Evrone company)
  • sugilog
  • Trond Arve Nordheim
  • Jan Szumiec
  • Jeff Browning
  • Bill Turner

Copyright 2008-2013 Zach Inglis, released under the MIT license

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言