Sha256: c6a94143632140a5dcf8e526d1b6a3da7cc0b0cd4da491546c24836d2b582939

Contents?: true

Size: 778 Bytes

Versions: 5

Compression:

Stored size: 778 Bytes

Contents

module Hydra
  module BlacklightHelperBehavior
    include Blacklight::BlacklightHelperBehavior
    
    ##
    # Given a Fedora uri, generate a reasonable partial name
    # Rails thinks that periods indicate a filename, so escape them with slashes.
    #
    # @param [SolrDocument] document
    # @param [String, Array] display_type a value suggestive of a partial
    # @return [String] the name of the partial to render
    # @example
    #   type_field_to_partial_name(["GenericContent"])
    #   => 'generic_content'
    #   type_field_to_partial_name(["text.pdf"])
    #   => 'text_pdf'
    def type_field_to_partial_name(document, display_type)
      str = Array(display_type).join(' '.freeze).underscore
      str.parameterize(separator: '_'.freeze)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hydra-core-13.0.0 app/helpers/hydra/blacklight_helper_behavior.rb
hydra-core-12.1.0 app/helpers/hydra/blacklight_helper_behavior.rb
hydra-core-12.0.2 app/helpers/hydra/blacklight_helper_behavior.rb
hydra-core-12.0.1 app/helpers/hydra/blacklight_helper_behavior.rb
hydra-core-12.0.0 app/helpers/hydra/blacklight_helper_behavior.rb