Class: ElementComponent::Components::Breadcrumb

Inherits:
Element
  • Object
show all
Defined in:
lib/element_component/components/breadcrumb.rb

Instance Attribute Summary

Attributes inherited from Element

#attributes, #contents, #element, #html

Instance Method Summary collapse

Methods inherited from Element

#add_attribute, #add_attribute!, #add_content, #add_content!, #new_element, #remove_attribute, #remove_attribute_value, #render, #reset_attributes!, #reset_contents!

Constructor Details

#initialize(**attributes) ⇒ Breadcrumb

Returns a new instance of Breadcrumb.



8
9
10
11
12
13
# File 'lib/element_component/components/breadcrumb.rb', line 8

def initialize(**attributes, &)
  super("nav", &)

  add_attribute("aria-label": "breadcrumb")
  add_attribute(attributes) unless attributes.empty?
end

Instance Method Details

#buildObject



15
16
17
18
19
20
21
22
23
# File 'lib/element_component/components/breadcrumb.rb', line 15

def build
  @html << "<#{@element}"
  @html << (mount_attributes.empty? ? ">" : " #{mount_attributes}>")
  @html << "<ol class=\"breadcrumb\">"
  @html << mount_content
  @html << "</ol>"
  @html << "</#{@element}>" if @closing_tag
  @html
end