Module: SolidusSeo::Helpers::BaseHelper
- Included in:
- MetaDataBuilder, Model
- Defined in:
- lib/solidus_seo/helpers/base_helper.rb
Instance Method Summary collapse
- #breadcrumb_pairs(taxon) ⇒ Object
- #plain_text(text) ⇒ Object
- #taxon_breadcrumbs_jsonld(taxon, separator = ' » ', list_class = 'list-inline', list_item_class = 'list-inline-item') ⇒ Object
Instance Method Details
#breadcrumb_pairs(taxon) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/solidus_seo/helpers/base_helper.rb', line 8 def (taxon) crumbs = [] if taxon crumbs << [Spree.t(:products), products_url] crumbs += taxon.ancestors.collect { |a| [a.name, spree.nested_taxons_url(a.permalink)] } unless taxon.ancestors.empty? crumbs << [taxon.name, spree.nested_taxons_url(taxon.permalink)] else crumbs << [Spree.t(:products), products_url] end crumbs end |
#plain_text(text) ⇒ Object
4 5 6 |
# File 'lib/solidus_seo/helpers/base_helper.rb', line 4 def plain_text(text) ActionController::Base.helpers.(text.to_s).gsub(/\s+/, ' ') end |
#taxon_breadcrumbs_jsonld(taxon, separator = ' » ', list_class = 'list-inline', list_item_class = 'list-inline-item') ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/solidus_seo/helpers/base_helper.rb', line 22 def (taxon, separator = ' » ', list_class = 'list-inline', list_item_class = 'list-inline-item') return '' if current_page?('/') || taxon.nil? separator = tag.span(separator.html_safe, class: 'breadcrumb-separator') original_output = Nokogiri::HTML::DocumentFragment.parse((taxon, separator, list_class).to_s) original_output.xpath('@itemscope|@itemtype|@itemprop|.//@itemscope|.//@itemtype|.//@itemprop').remove original_output.search('.columns').first['class'] = '' original_output.search('li').attr('class', list_item_class) ((taxon)) + original_output.to_s.html_safe end |