Method: Spree::BaseHelper#breadcrumbs

Defined in:
app/helpers/spree/base_helper.rb


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'app/helpers/spree/base_helper.rb', line 81

def breadcrumbs(taxon, separator=" » ", breadcrumb_class="inline")
  return "" if current_page?("/") || taxon.nil?

  crumbs = [[Spree.t(:home), spree.root_path]]

  if taxon
    crumbs << [Spree.t(:products), products_path]
    crumbs += taxon.ancestors.collect { |a| [a.name, spree.nested_taxons_path(a.permalink)] } unless taxon.ancestors.empty?
    crumbs << [taxon.name, spree.nested_taxons_path(taxon.permalink)]
  else
    crumbs << [Spree.t(:products), products_path]
  end

  separator = raw(separator)

  crumbs.map! do |crumb|
    (:li, itemscope:"itemscope", itemtype:"http://data-vocabulary.org/Breadcrumb") do
      link_to(crumb.last, itemprop: "url") do
        (:span, crumb.first, itemprop: "title")
      end + (crumb == crumbs.last ? '' : separator)
    end
  end

  (:nav, (:ul, raw(crumbs.map(&:mb_chars).join), class: breadcrumb_class), id: 'breadcrumbs', class: 'sixteen columns')
end