breadcrumb_helper 0.2.0 → 0.2.2
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/breadcrumb_helper.gemspec +1 -1
- data/lib/breadcrumb_helper/main.rb +5 -18
- data/lib/breadcrumb_helper/version.rb +1 -1
- data/lib/generators/templates/breadcrumb_items.html.erb +3 -7
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb75ceec6a60c04cd9a13843f9757d845f9f8a1052436fa9b840bb1dee576496
|
4
|
+
data.tar.gz: 39c79580ad386d632bc7daa0b7952103ccd801e239a1a76c2d7d7d57df15023e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb8271f47338e0be661c9644c8d36267e88b016f24ae15b10a76ab59b8598dc6f7fd53cecc40d0233515dc1e46bf3e176c56c688c8b6e99c6e14b17b3307ca88
|
7
|
+
data.tar.gz: bdbf5ebd8ee0a3a21e8a9f529187bdcb53c9f2d395565e10e167b98e76656194413dc3ef273cc3ef76326c0cf208999a65df42292d70e3e1401489639684ea51
|
data/README.md
CHANGED
@@ -95,7 +95,7 @@ end
|
|
95
95
|
|
96
96
|
With Crumb Stoppers, the breadcrumb trails will still display Home, and will not raise an exception.
|
97
97
|
|
98
|
-
Without Crumb Stoppers, the developer will need to add support for code *in each breadcrumb action*. To avoid this problem, the current default code of the gem is changed so that it stops the breadcrumb trail when it encounters a `NoMethodError` exception. Do note that it will still display the breadcrumbs that has no errors prior for a more beautiful display.
|
98
|
+
Without Crumb Stoppers, the developer will need to add support for code *in each breadcrumb action*. To avoid this problem, the current default code of the gem is changed so that it stops the breadcrumb trail when it encounters a `NoMethodError` exception. Do note that it will still display the breadcrumbs that has no errors prior for a more beautiful display.
|
99
99
|
|
100
100
|
## Contributing
|
101
101
|
|
data/breadcrumb_helper.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.require_paths = ['lib']
|
28
28
|
|
29
29
|
# Uncomment to register a new dependency of your gem
|
30
|
-
spec.add_dependency 'rails', '
|
30
|
+
spec.add_dependency 'rails', '>= 7', '< 9'
|
31
31
|
|
32
32
|
# For more information and examples about making a new gem, check out our
|
33
33
|
# guide at: https://bundler.io/guides/creating_gem.html
|
@@ -17,27 +17,14 @@ module BreadcrumbHelper
|
|
17
17
|
# Render the items to view as a string and html_safe on.
|
18
18
|
# Expected to find the partial in various locations thanks to Rails rendering.
|
19
19
|
def render_breadcrumb_items
|
20
|
-
|
20
|
+
begin
|
21
|
+
try("#{action_name}_breadcrumbs")
|
22
|
+
rescue NoMethodError
|
23
|
+
Rails.logger.warn("An error occurred in #{action_name}_breadcrumbs from #{controller_namespace}.")
|
24
|
+
end
|
21
25
|
render('breadcrumb_items', items: breadcrumb_items)
|
22
26
|
end
|
23
27
|
|
24
|
-
# Tries to render the item name.
|
25
|
-
# This is a dynamic value, hence this method exists so that it can become the interface for displaying item names
|
26
|
-
# with the benefit of added guard clauses.
|
27
|
-
# It is recommended to use this in the view files.
|
28
|
-
def render_breadcrumb_item_name(item)
|
29
|
-
item[:name].to_s
|
30
|
-
rescue NoMethodError
|
31
|
-
nil
|
32
|
-
end
|
33
|
-
|
34
|
-
# Tries to render the item path.
|
35
|
-
# It does nothing special, but support for it is added just in case there are updates.
|
36
|
-
# It is still more recommended to use this in the view files.
|
37
|
-
def render_breadcrumb_item_path(item)
|
38
|
-
item[:path]
|
39
|
-
end
|
40
|
-
|
41
28
|
private
|
42
29
|
|
43
30
|
# Absolute source of truth for breadcrumb items, only modifiable through add_breadcrumb method.
|
@@ -1,15 +1,11 @@
|
|
1
1
|
<% items.each do |item| %>
|
2
|
-
<%
|
3
|
-
<% break unless item_name %>
|
4
|
-
|
5
|
-
<% item_path = render_breadcrumb_item_path(item) %>
|
6
|
-
<% if item_path %>
|
2
|
+
<% if item[:path] %>
|
7
3
|
<li class="breadcrumb-item">
|
8
|
-
<a href="<%=
|
4
|
+
<a href="<%= item[:path] %>"><%= item[:name] %></a>
|
9
5
|
</li>
|
10
6
|
<% else %>
|
11
7
|
<li class="breadcrumb-item active" aria-current="page">
|
12
|
-
<%=
|
8
|
+
<%= item[:name] %>
|
13
9
|
</li>
|
14
10
|
<% end %>
|
15
11
|
<% end %>
|
metadata
CHANGED
@@ -1,30 +1,34 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breadcrumb_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tien
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-07 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rails
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
|
-
- - "
|
16
|
+
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '7'
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '9'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
23
25
|
requirements:
|
24
|
-
- - "
|
26
|
+
- - ">="
|
25
27
|
- !ruby/object:Gem::Version
|
26
28
|
version: '7'
|
27
|
-
|
29
|
+
- - "<"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '9'
|
28
32
|
email:
|
29
33
|
- tieeeeen1994@gmail.com
|
30
34
|
executables: []
|
@@ -50,7 +54,6 @@ licenses:
|
|
50
54
|
metadata:
|
51
55
|
homepage_uri: https://github.com/tieeeeen1994/rails-breadcrumb-helpers
|
52
56
|
rubygems_mfa_required: 'true'
|
53
|
-
post_install_message:
|
54
57
|
rdoc_options: []
|
55
58
|
require_paths:
|
56
59
|
- lib
|
@@ -65,8 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
68
|
- !ruby/object:Gem::Version
|
66
69
|
version: '0'
|
67
70
|
requirements: []
|
68
|
-
rubygems_version: 3.3
|
69
|
-
signing_key:
|
71
|
+
rubygems_version: 3.6.3
|
70
72
|
specification_version: 4
|
71
73
|
summary: Provides easy helper methods to generate breadcrumbs in Rails views.
|
72
74
|
test_files: []
|