lib/gretel/trails/strategies/hidden_strategy.rb
# Moves the trail from the querystring into a data attribute.
Moves the trail from the querystring into a data attribute.
Moves the trail from the querystring into a data attribute .
def breadcrumb_link_to_with_hidden_trail(name, url, options = {})
    if url.include?("#{Gretel::Trails.trail_param}=")
      uri = URI.parse(url)
      query_hash = Hash[CGI.parse(uri.query.to_s).map { |k, v| [k, v.first] }]
      trail = query_hash.delete(Gretel::Trails.trail_param.to_s)
      options = options.dup
      options[:data] ||= {}
      options[:data][Gretel::Trails::HiddenStrategy.data_attribute] = trail
      uri.query = query_hash.to_query.presence
      url = uri.to_s
    end
    breadcrumb_link_to_without_hidden_trail(name, url, options)
  end
def breadcrumb_link_to_with_hidden_trail ( name , url , options = { } ) if url . include? ( "#{Gretel::Trails.trail_param}=" ) uri = URI . parse ( url ) query_hash = Hash [ CGI . parse ( uri . query . to_s ) . map { | k , v | [ k , v . first ] } ] trail = query_hash . delete ( Gretel :: Trails . trail_param . to_s ) options = options . dup options [ :data ] ||= { } options [ :data ] [ Gretel :: Trails :: HiddenStrategy . data_attribute ] = trail uri . query = query_hash . to_query . presence url = uri . to_s end breadcrumb_link_to_without_hidden_trail ( name , url , options ) end
Moves the trail from the querystring into a data attribute.
Moves the trail from the querystring into a data attribute .
name
<not_specific>
url
<not_specific>
options
<not_specific>