Sha256: 9b2c637fdcc33b5c511fb900d5b02e26380788a3474444f1cb9e5fec6f293099

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'active_support/concern'
  
module Gitter
  module Breadcrumbs
    include Utils

    extend ActiveSupport::Concern

    def breadcrumbs
      @breadcrumbs ||= begin
        p = {}
        text = filters.map do |filter|
          p[filter.label] = filter_value(filter.name)
        end
        p
      end
    end

    def render_breadcrumbs delim = '>', params = {}
      delim_tag = h.content_tag :span, delim, {class: 'breadcrumb_delim'}

      p = {}
      breadcrumbs = filters.map do |filter|
        value = filter_value filter.name
        if value.present?
          s =  h.content_tag :span, "#{filter.label}:", class: 'breadcrumb_key'
          s += h.content_tag :span, value,              class: 'breadcrumb_value'            
          p[filter.name] = value
          h.link_to s, url_for(scoped_params(p).merge(params))
        else
          nil
        end
      end.compact

      if breadcrumbs.present? 
        h.content_tag :span, breadcrumbs.join(delim_tag), {class: 'breadcrumbs'}, false
      else
        nil
      end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gitter-1.1.5 lib/gitter/breadcrumbs.rb
gitter-1.1.4 lib/gitter/breadcrumbs.rb
gitter-1.1.3 lib/gitter/breadcrumbs.rb