Module: BreadcrumbHelper::Main
- Defined in:
- lib/breadcrumb_helper/main.rb
Overview
Contains the core code driver for breadcrumbs.
Instance Method Summary collapse
-
#add_breadcrumb(name:, path: nil) ⇒ Object
The method to add a breadcrumb item.
-
#breadcrumb_items ⇒ Object
Copy of breadcrumb items to prevent modification.
-
#render_breadcrumb_items ⇒ Object
Render the items to view as a string and html_safe on.
Instance Method Details
#add_breadcrumb(name:, path: nil) ⇒ Object
The method to add a breadcrumb item. Add more methods to the helper to modify breadcrumb items.
8 9 10 |
# File 'lib/breadcrumb_helper/main.rb', line 8 def (name:, path: nil) << { name: name, path: path } end |
#breadcrumb_items ⇒ Object
Copy of breadcrumb items to prevent modification.
13 14 15 |
# File 'lib/breadcrumb_helper/main.rb', line 13 def .dup.freeze end |
#render_breadcrumb_items ⇒ Object
Render the items to view as a string and html_safe on. Expected to find the partial in various locations thanks to Rails rendering.
19 20 21 22 23 24 25 26 |
# File 'lib/breadcrumb_helper/main.rb', line 19 def begin try("#{action_name}_breadcrumbs") rescue NoMethodError Rails.logger.warn("An error occurred in #{action_name}_breadcrumbs from #{controller_namespace}.") end render('breadcrumb_items', items: ) end |