app/helpers/blacklight/hierarchy_helper.rb
# Putting bare HTML strings in a helper sucks. But in this case, with a
# lot of recursive tree-walking going on, it's an order of magnitude faster
# than either render(:partial) or content_tag
Putting bare HTML strings in a helper sucks. But in this case, with a
lot of recursive tree-walking going on, it's an order of magnitude faster
than either render(:partial) or content_tag
Putting bare HTML strings in a helper sucks . But in this case with a lot of recursive tree - walking going on it ' s an order of magnitude faster than either render ( : partial ) or content_tag
def render_facet_hierarchy_item(field_name, data, key)
    item = data[:_]
    subset = data.reject { |k, _v| !k.is_a?(String) }
    li_class = subset.empty? ? 'h-leaf' : 'h-node'
    ul = ''
    li = if item.nil?
           key
         elsif facet_in_params?(field_name, item.qvalue)
           render_selected_qfacet_value(field_name, item)
         else
           render_qfacet_value(field_name, item)
         end
    unless subset.empty?
      subul = subset.keys.sort.collect do |subkey|
        render_facet_hierarchy_item(field_name, subset[subkey], subkey)
      end.join('')
      ul = "<ul>#{subul}</ul>".html_safe
    end
    %(<li class="#{li_class}">#{li.html_safe}#{ul.html_safe}</li>).html_safe
  end
def render_facet_hierarchy_item ( field_name , data , key ) item = data [ :_ ] subset = data . reject { | k , _v | ! k . is_a? ( String ) } li_class = subset . empty? ? 'h-leaf' : 'h-node' ul = '' li = if item . nil? key elsif facet_in_params? ( field_name , item . qvalue ) render_selected_qfacet_value ( field_name , item ) else render_qfacet_value ( field_name , item ) end unless subset . empty? subul = subset . keys . sort . collect do | subkey | render_facet_hierarchy_item ( field_name , subset [ subkey ] , subkey ) end . join ( '' ) ul = "<ul>#{subul}</ul>" . html_safe end %(<li class="#{li_class}">#{li.html_safe}#{ul.html_safe}</li>) . html_safe end
Putting bare HTML strings in a helper sucks.
Putting bare HTML strings in a helper sucks .
field_name
<not_specific>
data
<not_specific>
key
<not_specific>