Class: ElementComponent::Components::Breadcrumb
- Defined in:
- lib/element_component/components/breadcrumb.rb
Instance Attribute Summary
Attributes inherited from Element
#attributes, #contents, #element, #html
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(**attributes) ⇒ Breadcrumb
constructor
A new instance of Breadcrumb.
Methods inherited from Element
#add_attribute, #add_attribute!, #add_content, #add_content!, #new_element, #remove_attribute, #remove_attribute_value, #render, #render_in, #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
#build ⇒ Object
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 |