Class: Bulmacomp::BreadcrumbComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Bulmacomp::BreadcrumbComponent
- Defined in:
- app/components/bulmacomp/breadcrumb_component.rb
Overview
Make an html structure for a bulma breadcrumb
Instance Method Summary collapse
-
#call ⇒ String
Html_safe breadcrumb.
-
#initialize(elements: [], **opts) {|optional| ... } ⇒ BreadcrumbComponent
constructor
A new instance of BreadcrumbComponent.
-
#ul_content ⇒ Text
, safe join of elements arguments and proc content.
Constructor Details
#initialize(elements: [], **opts) {|optional| ... } ⇒ BreadcrumbComponent
Returns a new instance of BreadcrumbComponent.
42 43 44 45 46 |
# File 'app/components/bulmacomp/breadcrumb_component.rb', line 42 def initialize(elements: [], **opts) super @elements = elements @opts = { class: 'breadcrumb', aria: { label: 'breadcrumbs' } }.merge(opts) end |
Instance Method Details
#call ⇒ String
Returns html_safe breadcrumb.
49 50 51 |
# File 'app/components/bulmacomp/breadcrumb_component.rb', line 49 def call tag.nav tag.ul(ul_content), **@opts end |
#ul_content ⇒ Text
Returns , safe join of elements arguments and proc content.
54 55 56 |
# File 'app/components/bulmacomp/breadcrumb_component.rb', line 54 def ul_content safe_join(@elements.map { |e| tag.li(e) }.<<(content)) end |