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.
59 60 61 |
# File 'lib/proscenium/ui/breadcrumbs/control.rb', line 59 def (name, path = nil, = {}) << Element.new(name, path, ) end |
#breadcrumbs ⇒ Object
73 74 75 |
# File 'lib/proscenium/ui/breadcrumbs/control.rb', line 73 def @breadcrumbs ||= [] end |
#breadcrumbs_as_json ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/proscenium/ui/breadcrumbs/control.rb', line 77 def .map do |ele| path = ele.path { name: ele.name, path: ele.path.nil? || view_context.current_page?(path) ? nil : path } end end |
#breadcrumbs_for_title(primary: false) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/proscenium/ui/breadcrumbs/control.rb', line 86 def (primary: false) names = .map(&:name) return names.pop if primary out = [names.pop] out << names.join(': ') if !names.empty? out.join(' - ') end |