美味的面包碎片! 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 is a simple and tasty way to add breadcrumbs to your Rails applications.
Simply add the dependency to your Gemfile:
gem "crummy", "~> 1.8.0"In your controllers you may add_crumb either like a before_filter or within a method (It is also available to views).
class ApplicationController
add_crumb "Home", '/'
end
class BusinessController You can set the html options with link_html_options. These are added to the a tag.
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.
add_crumb "Support".html_safe, "", {}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
format: (:html|:html_list|:xml)The separator text. It does not assume you want spaces on either side so
you must specify. Defaults to » for :html and
`` for :xml
separator: stringRender links in the output. Defaults to true
links: falseRender Richsnipet Default to false
microdata: trueOptionally disable linking of the last crumb, Defaults to true
last_crumb_linked: falseWith this option, output will be blank if there are no breadcrumbs.
skip_if_blank: true…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
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:
Crummy.configure do |config|
config.format = :xml
endPossible parameters for configuration are:
: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_sideSee lib/crummy.rb for a list of these parameters and their defaults.
###Individually for each crumb configuration:
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.
An example application is available right inside this gem. That application is documented, see example/README for details about usage.
Copyright 2008-2013 Zach Inglis, released under the MIT license
暂无开放 Issues,或尚未同步最近议题。