Class: Components::Breadcrumb

Inherits:
Base
  • Object
show all
Defined in:
lib/backpack/components/breadcrumb.rb

Defined Under Namespace

Classes: Item

Constant Summary

Constants included from Backpack::Attributes

Backpack::Attributes::HTMLAttribute, Backpack::Attributes::HTMLAttributes, Backpack::Attributes::MandatoryHTMLAttribute

Instance Method Summary collapse

Methods included from Backpack::Classes

#root_classes

Methods included from Backpack::Identifier

#identifier

Instance Method Details

#itemObject



39
40
41
42
# File 'lib/backpack/components/breadcrumb.rb', line 39

def item(**, &)
  @items << Item.new(breadcrumb: self, **, &)
  nil
end

#view_templateObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/backpack/components/breadcrumb.rb', line 25

def view_template(&)
  vanish(&) # like yield but ensures it can’t output HTML

  return unless @items.any?

  nav(**root_attributes) do
    ol do
      @items.each_with_index do |item, _index|
        render item
      end
    end
  end
end