gretel-lite 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.travis.yml +16 -0
  4. data/CHANGELOG.md +56 -0
  5. data/Gemfile +23 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +376 -0
  8. data/Rakefile +10 -0
  9. data/gemfiles/Gemfile-rails.3.1.x +19 -0
  10. data/gemfiles/Gemfile-rails.3.2.x +19 -0
  11. data/gemfiles/Gemfile-rails.4.0.x +19 -0
  12. data/gemfiles/Gemfile-rails.4.1.x +19 -0
  13. data/gretel.gemspec +23 -0
  14. data/lib/generators/gretel/USAGE +8 -0
  15. data/lib/generators/gretel/install_generator.rb +12 -0
  16. data/lib/generators/gretel/templates/breadcrumbs.rb +28 -0
  17. data/lib/gretel.rb +82 -0
  18. data/lib/gretel/crumb.rb +68 -0
  19. data/lib/gretel/crumbs.rb +64 -0
  20. data/lib/gretel/deprecated.rb +1 -0
  21. data/lib/gretel/deprecated/default_style_key.rb +25 -0
  22. data/lib/gretel/deprecated/layout.rb +15 -0
  23. data/lib/gretel/deprecated/show_root_alone.rb +27 -0
  24. data/lib/gretel/deprecated/yield_links.rb +44 -0
  25. data/lib/gretel/link.rb +39 -0
  26. data/lib/gretel/renderer.rb +254 -0
  27. data/lib/gretel/resettable.rb +13 -0
  28. data/lib/gretel/version.rb +3 -0
  29. data/lib/gretel/view_helpers.rb +71 -0
  30. data/test/deprecated_test.rb +45 -0
  31. data/test/dummy/Rakefile +7 -0
  32. data/test/dummy/app/assets/javascripts/application.js +15 -0
  33. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  34. data/test/dummy/app/controllers/application_controller.rb +3 -0
  35. data/test/dummy/app/helpers/application_helper.rb +5 -0
  36. data/test/dummy/app/mailers/.gitkeep +0 -0
  37. data/test/dummy/app/models/.gitkeep +0 -0
  38. data/test/dummy/app/models/issue.rb +3 -0
  39. data/test/dummy/app/models/project.rb +3 -0
  40. data/test/dummy/app/views/breadcrumbs/site.rb +3 -0
  41. data/test/dummy/config.ru +4 -0
  42. data/test/dummy/config/application.rb +14 -0
  43. data/test/dummy/config/boot.rb +10 -0
  44. data/test/dummy/config/breadcrumbs.rb +3 -0
  45. data/test/dummy/config/breadcrumbs/test_crumbs.rb +85 -0
  46. data/test/dummy/config/database.yml +25 -0
  47. data/test/dummy/config/environment.rb +5 -0
  48. data/test/dummy/config/environments/development.rb +2 -0
  49. data/test/dummy/config/environments/production.rb +2 -0
  50. data/test/dummy/config/environments/test.rb +2 -0
  51. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  52. data/test/dummy/config/initializers/inflections.rb +15 -0
  53. data/test/dummy/config/initializers/mime_types.rb +5 -0
  54. data/test/dummy/config/initializers/secret_token.rb +7 -0
  55. data/test/dummy/config/initializers/session_store.rb +8 -0
  56. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  57. data/test/dummy/config/locales/en.yml +5 -0
  58. data/test/dummy/config/routes.rb +11 -0
  59. data/test/dummy/db/migrate/20130122163007_create_projects.rb +9 -0
  60. data/test/dummy/db/migrate/20130122163051_create_issues.rb +10 -0
  61. data/test/dummy/db/schema.rb +29 -0
  62. data/test/dummy/lib/assets/.gitkeep +0 -0
  63. data/test/dummy/log/.gitkeep +0 -0
  64. data/test/dummy/public/404.html +26 -0
  65. data/test/dummy/public/422.html +26 -0
  66. data/test/dummy/public/500.html +25 -0
  67. data/test/dummy/public/favicon.ico +0 -0
  68. data/test/dummy/script/rails +6 -0
  69. data/test/fixtures/issues.yml +4 -0
  70. data/test/fixtures/projects.yml +3 -0
  71. data/test/gretel_test.rb +24 -0
  72. data/test/helper_methods_test.rb +546 -0
  73. data/test/test_helper.rb +15 -0
  74. metadata +205 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c04b679c18361079f9f8fe3df99d49ffa7cafcab
4
+ data.tar.gz: b293fea5337686ec2e02fb883858d2c9d7ad7eab
5
+ SHA512:
6
+ metadata.gz: 429c53daa512ff2dbc21246f351ceb51f2bb6ccca77766c92f00cf9e521b772c9b4a03ca6ff504d967e404a7b2609005b4d39a2c3bf92053cc54b1a406428823
7
+ data.tar.gz: 2657ab28f5dba0e60878e91a92b4fd65de6d21f16f78cfe4307ecf9c77c94759c2a973a3054c02978b3188837dc05c338b1beaa183a3b0c3d0626539bfd68e4f
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ gemfiles/*.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ log/*.log
20
+ test/dummy/db/*.sqlite3
21
+ test/dummy/log/*.log
22
+ test/dummy/tmp/
23
+ test/dummy/.sass-cache
24
+ .DS_Store
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ sudo: false
3
+ rvm:
4
+ - 2.2.0
5
+ - 2.1.0
6
+ - 2.0.0
7
+ - 1.9.3
8
+ gemfile:
9
+ - gemfiles/Gemfile-rails.3.1.x
10
+ - gemfiles/Gemfile-rails.3.2.x
11
+ - gemfiles/Gemfile-rails.4.0.x
12
+ - gemfiles/Gemfile-rails.4.1.x
13
+ before_script:
14
+ - "cd test/dummy; rake db:migrate; rake db:test:prepare; cd ../.."
15
+ notifications:
16
+ email: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,56 @@
1
+ # Changelog
2
+
3
+ ## Version 3.0.9
4
+ * Adds breadcrumbs option `link_current_to_request_path` to link the current breadcrumb to the request path(#28 via #29)
5
+ * Fixes semantic breadcrumbs when the last item has no link (via #55)
6
+ * Downgrades Rails dependency to 3.1 (via #56)
7
+ * Fixes jRuby issue with `Rails::Application` constant (via #50)
8
+ * Fixes deprecation warnings for `alias_method_chain` (via #66)
9
+ * Updated coprights (via #63)
10
+
11
+ ## Version 3.0.8
12
+ * Parent breadcrumbs can now also be inferred from models responding to `model_name`.
13
+
14
+ ## Version 3.0.7
15
+ * Pretext and posttext classes are now customizable with `<%= breadcrumbs pretext_class: "some-class" %>` and `<%= breadcrumbs posttext_class: "some-other-class" %>`.
16
+
17
+ ## Version 3.0.6
18
+ * Pretext and posttext are now enclosed in spans with `<span class="pretext">` and `<span class="posttext">`.
19
+ * Semantic breadcrumbs are now rendered in spans instead of divs to enable easier styling.
20
+
21
+ ## Version 3.0.3
22
+ * Breadcrumbs can now be rendered for use in the [Foundation 5](http://foundation.zurb.com/) framework. Use `breadcrumbs style: :foundation5`.
23
+ * Breadcrumbs are now automatically loaded from any engines' `config/breadcrumbs.rb` and `config/breadcrumbs/**/*.rb`. See the readme for details.
24
+ * You can now pass options to links to be used when you render manually. See the readme for details.
25
+ * Breadcrumb configuration files can now be put in the `app/views/breadcrumbs/` folder. This is an experimental feature that may replace loading breadcrumbs from the `config` folder in the future.
26
+
27
+ ## Version 3.0.2
28
+ * Inferring breadcrumbs is now supported on all instances of objects that respond to `model_name`.
29
+
30
+ ## Version 3.0.1
31
+ * Breadcrumbs can now be inferred if you pass in an ActiveRecord model instance. E.g. `breadcrumb @product` is short for `breadcrumb :product, @product`.
32
+
33
+ ## Version 3.0
34
+ * Support for defining breadcrumbs using `Gretel::Crumbs.layout do ... end` in an initializer has been removed. See the readme for details on how to upgrade.
35
+ * Breadcrumbs rendering is now done in a separate class to unclutter the view with helpers. The public API is still the same.
36
+ * Support for rendering the breadcrumbs in different styles like ul- and ol lists, and for use with [Twitter Bootstrap](http://getbootstrap.com/). See the `:style` option in the readme for more info.
37
+ * The `:show_root_alone` option is now called `:display_single_fragment` and can be used to display the breadcrumbs only when there are more than one link, also if it is not the root breadcrumb.
38
+ * Links yielded from `<%= breadcrumbs do |links| %>` now have a `current?` helper that returns true if the link is the last in the trail.
39
+ * New view helper: `parent_breadcrumb` returns the parent breadcrumb link (with `#key`, `#text`, and `#url`). This can for example be used to create a dynamic back link. You can supply options like `:autoroot` etc.
40
+ If you supply a block, it will yield the parent breadcrumb if it is present.
41
+
42
+ ## Version 2.1
43
+ * Breadcrumbs are now configured in `config/breadcrumbs.rb` and `config/breadcrumbs/**/*.rb` and reloaded when changed in the development environment instead of the initializer that required restart when configuration changed.
44
+
45
+ ## Version 2.0
46
+
47
+ * Totally rewritten for better structure.
48
+ * `options[:autoroot]` is now `true` by default which means it will automatically link to the `:root` breadcrumb if no parent is specified.
49
+ * Now accepts `options[:class]` for specifying the CSS class for the breadcrumbs container. Default: `"breadcrumbs"`.
50
+ * Now accepts `options[:current_class]` for specifying the CSS class for the current link / span. Default: `"current"`.
51
+ * `options[:link_last]` was deprecated in a previous version and is now removed. Use `options[:link_current]` instead.
52
+ * The `link` method in `crumb :xx do ... end` no longer takes HTML options. The method for this is now by building the breadcrumbs manually (see the readme).
53
+ * No longer supports procs for link text or URL as this is unnecessary when you can pass arguments to the block anyway.
54
+ * It now accepts multiple arguments for `crumb` and `parent` (see the readme).
55
+ * Breadcrumbs are now rendered with `<%= breadcrumbs %>`, although you can still use the old `<%= breadcrumb %>` (without *s*).
56
+ * You can now access view helpers from inside `Gretel::Crumbs.layout do .. end`.
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in gretel.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ # To use debugger
14
+ # gem 'debugger'
15
+
16
+ group :development do
17
+ # jquery-rails is used by the dummy application
18
+ gem "jquery-rails"
19
+ end
20
+
21
+ group :test do
22
+ gem 'test-unit', '~> 3.0' if RUBY_VERSION >= "2.2"
23
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2010-2016 Lasse Bunk
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,376 @@
1
+ ## Fork of gretel removing dependency on rails gem and using more granual dependencies instead
2
+
3
+
4
+ <a href="http://travis-ci.org/lassebunk/gretel"><img src="https://secure.travis-ci.org/lassebunk/gretel.png" alt="Build Status" /></a>
5
+
6
+ <img src="http://i.imgur.com/CAKEaBM.png" alt="Handle breadcrumb trails... like a boss :)" />
7
+
8
+ ([TL;DR](http://i.imgur.com/nH25yiH.png)) Gretel is a [Ruby on Rails](http://rubyonrails.org) plugin that makes it easy yet flexible to create breadcrumbs.
9
+ It is based around the idea that breadcrumbs are a concern of the view, so you define a set of breadcrumbs in *config/breadcrumbs.rb* (or multiple files; see below) and specify in the view which breadcrumb to use.
10
+ Gretel also supports [semantic breadcrumbs](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=185417) (those used in Google results).
11
+
12
+ Have fun! And please do write, if you (dis)like it – [lassebunk@gmail.com](mailto:lassebunk@gmail.com).
13
+
14
+ ## Installation
15
+
16
+ In your *Gemfile*:
17
+
18
+ ```ruby
19
+ gem "gretel"
20
+ ```
21
+
22
+ And run:
23
+
24
+ ```bash
25
+ $ bundle install
26
+ ```
27
+
28
+ ## Example
29
+
30
+ Start by generating breadcrumbs configuration file:
31
+
32
+ ```bash
33
+ $ rails generate gretel:install
34
+ ```
35
+
36
+ Then, in *config/breadcrumbs.rb*:
37
+
38
+ ```ruby
39
+ # Root crumb
40
+ crumb :root do
41
+ link "Home", root_path
42
+ end
43
+
44
+ # Issue list
45
+ crumb :issues do
46
+ link "All issues", issues_path
47
+ end
48
+
49
+ # Issue
50
+ crumb :issue do |issue|
51
+ link issue.title, issue
52
+ parent :issues
53
+ end
54
+ ```
55
+
56
+ At the top of *app/views/issues/show.html.erb*, set the current breadcrumb (assuming you have loaded `@issue` with an issue):
57
+
58
+ ```erb
59
+ <% breadcrumb :issue, @issue %>
60
+ ```
61
+
62
+ Then, in *app/views/layouts/application.html.erb*:
63
+
64
+ ```erb
65
+ <%= breadcrumbs pretext: "You are here: ",
66
+ separator: " &rsaquo; " %>
67
+ ```
68
+
69
+ This will generate the following HTML (indented for readability):
70
+
71
+ ```html
72
+ <div class="breadcrumbs">
73
+ <span class="pretext">You are here:</span>
74
+ <a href="/">Home</a> &rsaquo;
75
+ <a href="/issues">All issues</a> &rsaquo;
76
+ <span class="current">My Issue</span>
77
+ </div>
78
+ ```
79
+
80
+ ## Options
81
+
82
+ You can pass options to `<%= breadcrumbs %>`, e.g. `<%= breadcrumbs pretext: "You are here: " %>`:
83
+
84
+ Option | Description | Default
85
+ ------------------------ | -------------------------------------------------------------------------------------------------------------------------- | -------
86
+ :style | How to render the breadcrumbs. Can be `:inline`, `:ol`, `:ul`, or `:bootstrap`. See below for more info. | `:inline`
87
+ :pretext | Text to be rendered before breadcrumb, e.g. `"You are here: "`. | None
88
+ :posttext | Text to be appended after breadcrumb, e.g. `"Text after breacrumb"`, | None
89
+ :separator | Separator between links, e.g. `" &rsaquo; "`. | `" &rsaquo; "`
90
+ :autoroot | Whether it should automatically link to the `:root` crumb if no parent is given. | True
91
+ :display_single_fragment | Whether it should display the breadcrumb if it includes only one link. | False
92
+ :link_current | Whether the current crumb should be linked to. | False
93
+ :link_current_to_request_path | Whether the current crumb should always link to the current request path. *Note:* This option will have no effect unless `:link_current` is set to `true`. | True
94
+ :semantic | Whether it should generate [semantic breadcrumbs](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=185417). | False
95
+ :id | ID for the breadcrumbs container. | None
96
+ :class | CSS class for the breadcrumbs container. Can be set to `nil` for no class. | `"breadcrumbs"`
97
+ :current_class | CSS class for the current link or span. Can be set to `nil` for no class. | `"current"`
98
+ :pretext_class | CSS class for the pretext, if given. Can be set to `nil` for no class. | `"pretext"`
99
+ :posttext_class | CSS class for the posttext, if given. Can be set to `nil` for no class. | `"posttext"`
100
+ :container_tag | Tag type that contains the breadcrumbs. | `:div`
101
+ :fragment_tag | Tag type to contain each breadcrumb fragment/link. | None
102
+
103
+ ### Styles
104
+
105
+ These are the styles you can use with `breadcrumbs style: :xx`.
106
+
107
+ Style | Description
108
+ -------------- | -----------
109
+ `:inline` | Renders each link by itself with `&rsaquo;` as the seperator.
110
+ `:ol` | Renders the links in `<li>` elements contained in an outer `<ol>`.
111
+ `:ul` | Renders the links in `<li>` elements contained in an outer `<ul>`.
112
+ `:bootstrap` | Renders the links for use in [Twitter Bootstrap](http://getbootstrap.com/).
113
+ `:foundation5` | Renders the links for use in [Foundation 5](http://foundation.zurb.com/).
114
+
115
+ Or you can build the breadcrumbs manually for full customization; see below.
116
+
117
+ If you add other widely used styles, please submit a [Pull Request](https://github.com/lassebunk/gretel/pulls) so others can use them too.
118
+
119
+ ## More examples
120
+
121
+ In *config/breadcrumbs.rb*:
122
+
123
+ ```ruby
124
+ # Root crumb
125
+ crumb :root do
126
+ link "Home", root_path
127
+ end
128
+
129
+ # Regular crumb
130
+ crumb :projects do
131
+ link "Projects", projects_path
132
+ end
133
+
134
+ # Parent crumbs
135
+ crumb :project_issues do |project|
136
+ link "Issues", project_issues_path(project)
137
+ parent project # inferred to :project
138
+ end
139
+
140
+ # Child
141
+ crumb :issue do |issue|
142
+ link issue.name, issue_path(issue)
143
+ parent :project_issues, issue.project
144
+ end
145
+
146
+ # Recursive parent categories
147
+ crumb :category do |category|
148
+ link category.name, category
149
+ if category.parent
150
+ parent category.parent # inferred to :category
151
+ else
152
+ parent :categories
153
+ end
154
+ end
155
+
156
+ # Product crumb with recursive parent categories (as defined above)
157
+ crumb :product do |product|
158
+ link product.name, product
159
+ parent product.category # inferred to :category
160
+ end
161
+
162
+ # Crumb with multiple links
163
+ crumb :test do
164
+ link "One", one_path
165
+ link "Two", two_path
166
+ parent :about
167
+ end
168
+
169
+ # Example of using params to alter the parent, e.g. to
170
+ # match the user's actual navigation path
171
+ # URL: /products/123?q=my+search
172
+ crumb :search do |keyword|
173
+ link "Search for #{keyword}", search_path(q: keyword)
174
+ end
175
+
176
+ crumb :product do |product|
177
+ if keyword = params[:q].presence
178
+ parent :search, keyword
179
+ else # default
180
+ parent product.category # inferred to :category
181
+ end
182
+ end
183
+
184
+ # Multiple arguments
185
+ crumb :multiple_test do |a, b, c|
186
+ link "Test #{a}, #{b}, #{c}", test_path
187
+ parent :other_test, 3, 4, 5
188
+ end
189
+
190
+ # Breadcrumb without link URL; will not generate a link
191
+ crumb :without_link do
192
+ link "Breadcrumb without link"
193
+ end
194
+
195
+ # Breadcrumb using view helper
196
+ module UsersHelper
197
+ def user_name_for(user)
198
+ user.name
199
+ end
200
+ end
201
+
202
+ crumb :user do |user|
203
+ link user_name_for(user), user
204
+ end
205
+ ```
206
+
207
+ ## Building the breadcrumbs manually
208
+
209
+ If you supply a block to the `breadcrumbs` method, it will yield an array with the breadcrumb links so you can build the breadcrumbs HTML manually:
210
+
211
+ ```erb
212
+ <% breadcrumbs do |links| %>
213
+ <% if links.any? %>
214
+ You are here:
215
+ <% links.each do |link| %>
216
+ <%= link_to link.text, link.url, class: (link.current? ? "current" : nil) %> (<%= link.key %>)
217
+ <% end %>
218
+ <% end %>
219
+ <% end %>
220
+ ```
221
+
222
+ ## Getting the parent breadcrumb
223
+
224
+ If you want to add a link to the parent breadcrumb, you can use the `parent_breadcrumb` view helper.
225
+ By default it returns a link instance that has the properties `#key`, `#text`, and `#url`.
226
+ You can supply options like `autoroot: false` etc.
227
+
228
+ If you supply a block, it will yield the link if it is present:
229
+
230
+ ```erb
231
+ <% parent_breadcrumb do |link| %>
232
+ <%= link_to "Back to #{link.text}", link.url %>
233
+ <% end %>
234
+ ```
235
+
236
+ ## Nice to know
237
+
238
+ ### Access to view methods
239
+
240
+ When configuring breadcrumbs inside a `crumb :xx do ... end` block, you have access to all methods that are normally accessible in the view where the breadcrumbs are inserted. This includes your view helpers, `params`, `request`, etc.
241
+
242
+ ### Using multiple breadcrumb configuration files
243
+
244
+ If you have a large site and you want to split your breadcrumbs configuration over multiple files, you can create a folder named `config/breadcrumbs` and put your configuration files (e.g. `products.rb` or `frontend.rb`) in there.
245
+ The format is the same as `config/breadcrumbs.rb` which is also loaded.
246
+
247
+ ### Loading breadcrumbs from engines
248
+
249
+ Breadcrumbs are automatically loaded from any engines' `config/breadcrumbs.rb` and `config/breadcrumbs/**/*.rb`.
250
+ Breadcrumbs defined in your main app will override breadcrumbs from engines.
251
+
252
+ ### Inferring breadcrumbs
253
+
254
+ Breadcrumbs can be automatically inferred if you pass an instance of an object that responds to `model_name` (like an ActiveRecord model instance).
255
+
256
+ For example:
257
+
258
+ ```erb
259
+ <% breadcrumb @product %>
260
+ ```
261
+
262
+ is short for
263
+
264
+ ```erb
265
+ <% breadcrumb :product, @product %>
266
+ ```
267
+
268
+ ### Passing options to links
269
+
270
+ You can pass options to links to be used when you render breadcrumbs manually.
271
+
272
+ In *config/breadcrumbs.rb*:
273
+
274
+ ```ruby
275
+ crumb :something do
276
+ link "My Link", my_path, title: "My Title", other: "My Other Option"
277
+ end
278
+ ```
279
+
280
+ Example methods you can then use in the view:
281
+
282
+ ```ruby
283
+ breadcrumbs do |links|
284
+ links.each do |link|
285
+ link.title? # => true
286
+ link.title # => "My Title"
287
+ link.other? # => true
288
+ link.other # => "My Other Option"
289
+ link.nonexisting_option? # => false
290
+ link.nonexisting_option # => nil
291
+ end
292
+ end
293
+ ```
294
+
295
+ ### Automatic reloading of breadcrumb configuration files
296
+
297
+ Since Gretel version 2.1.0, the breadcrumb configuration files are now reloaded in the Rails development environment if they change. In other environments, like production, the files are loaded once, when first needed.
298
+
299
+ ### Setting breadcrumb trails
300
+
301
+ The [gretel-trails](https://github.com/lassebunk/gretel-trails) gem can handle adding and hiding trails from the URL automatically. This makes it possible to link back to a different breadcrumb trail than the one specified in your breadcrumb, for example if you have a
302
+ store with products that have a default parent to the category breadcrumb, but when visiting from the reviews section, you want to link back to the reviews instead.
303
+
304
+ You can apply trails to select links by adding a simple JS selector (`js-append-trail` or another you choose), and after each page load it hides the trail from the URL, so the server sees it but the users don't.
305
+
306
+ Check out the gem [here](https://github.com/lassebunk/gretel-trails).
307
+
308
+
309
+ ## Upgrading from version 2.0 or below
310
+
311
+ Instead of using the initializer that in Gretel version 2.0 and below required restarting the application after breadcrumb configuration changes, the configuration of the breadcrumbs is now loaded from `config/breadcrumbs.rb` (and `config/breadcrumbs/*.rb` if you want to split your breadcrumbs configuration across multiple files).
312
+ In the Rails development environment, these files are automatically reloaded when changed.
313
+
314
+ Using the initializer (e.g. `config/initializers/breadcrumbs.rb`) was deprecated in Gretel version 2.1.0 and removed in version 3.0. It raises an error if you try to use it.
315
+
316
+ To update to the latest version of Gretel, use `bundle update gretel`. Then remove the `Gretel::Crumbs.layout do ... end` block, so instead of:
317
+
318
+ ```ruby
319
+ Gretel::Crumbs.layout do
320
+ crumb :root do
321
+ link "Home", root_path
322
+ end
323
+ end
324
+ ```
325
+
326
+ in the initializer, you write:
327
+
328
+ ```ruby
329
+ crumb :root do
330
+ link "Home", root_path
331
+ end
332
+ ```
333
+
334
+ in `config/breadcrumbs.rb`.
335
+
336
+ ## Documentation
337
+
338
+ * [Full documentation](http://rubydoc.info/gems/gretel)
339
+ * [Changelog](https://github.com/lassebunk/gretel/blob/master/CHANGELOG.md)
340
+ * [Tutorial on using Gretel](http://www.sitepoint.com/breadcrumbs-rails-gretel/) (Sitepoint)
341
+
342
+ ## Versioning
343
+
344
+ Follows [semantic versioning](http://semver.org/).
345
+
346
+ ## Contributing
347
+
348
+ You are very welcome to help improve Gretel if you have suggestions for features that other people can use.
349
+
350
+ To contribute:
351
+
352
+ 1. Fork the project
353
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
354
+ 3. Make your changes
355
+ 4. Add/Fix tests
356
+ 5. Prepare database for testing: `cd test/dummy; rake db:migrate; rake db:test:prepare; cd ../..`
357
+ 6. Run `rake` to make sure all tests pass
358
+ 7. Commit your changes (`git commit -am 'Add new feature'`)
359
+ 8. Push to the branch (`git push origin my-new-feature`)
360
+ 9. Create new pull request
361
+
362
+ Thanks.
363
+
364
+ ## Contributors
365
+
366
+ Gretel was created by [@lassebunk](https://github.com/lassebunk) and is maintained by [@WilHall](https://github.com/WilHall).
367
+
368
+ [See the list of contributors](https://github.com/lassebunk/gretel/graphs/contributors)
369
+
370
+ ## And then
371
+
372
+ <img src="http://i.imgur.com/u4Wbt4n.png" alt="After using Gretel, you'll be like this" />
373
+
374
+ Have fun!
375
+
376
+ Copyright (c) 2010-2016 [Lasse Bunk](http://lassebunk.dk), released under the MIT license