Module: Proscenium::UI::Breadcrumbs::Control
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActionView::Helpers::SanitizeHelper
- Defined in:
- lib/proscenium/ui/breadcrumbs/control.rb
Overview
Include this module in your controller to add support for adding breadcrumb elements. You can then use the ‘add_breadcrumb` and `prepend_breadcrumb` class methods to append and/or prepend breadcrumb elements.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#add_breadcrumb(name, path = nil, options = {}) ⇒ Object
Pushes a new breadcrumb element into the collection.
- #breadcrumbs ⇒ Object
- #breadcrumbs_as_json ⇒ Object
- #breadcrumbs_for_title(primary: false) ⇒ Object
-
#prepend_breadcrumb(name, path = nil, options = {}) ⇒ Object
Prepend a new breadcrumb element into the collection.
Instance Method Details
#add_breadcrumb(name, path = nil, options = {}) ⇒ Object
Pushes a new breadcrumb element into the collection.
51 52 53 |
# File 'lib/proscenium/ui/breadcrumbs/control.rb', line 51 def (name, path = nil, = {}) << Element.new(name, path, ) end |
#breadcrumbs ⇒ Object
65 66 67 |
# File 'lib/proscenium/ui/breadcrumbs/control.rb', line 65 def @breadcrumbs ||= [] end |
#breadcrumbs_as_json ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/proscenium/ui/breadcrumbs/control.rb', line 69 def .map do |ele| path = ele.path { name: ele.name, path: ele.path.nil? || helpers.current_page?(path) ? nil : path } end end |
#breadcrumbs_for_title(primary: false) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/proscenium/ui/breadcrumbs/control.rb', line 78 def (primary: false) names = .map(&:name) return names.pop if primary out = [names.pop] out << names.join(': ') unless names.empty? out.join(' - ') end |