Module: Hydra::BlacklightHelperBehavior

Includes:
Blacklight::BlacklightHelperBehavior
Included in:
BlacklightHelper
Defined in:
app/helpers/hydra/blacklight_helper_behavior.rb

Instance Method Summary collapse

Instance Method Details

#type_field_to_partial_name(document, display_type) ⇒ String

Given a Fedora uri, generate a reasonable partial name Rails thinks that periods indicate a filename, so escape them with slashes.

Examples:

type_field_to_partial_name(["GenericContent"])
=> 'generic_content'
type_field_to_partial_name(["text.pdf"])
=> 'text_pdf'

Parameters:

  • document (SolrDocument)
  • display_type (String, Array)

    a value suggestive of a partial

Returns:

  • (String)

    the name of the partial to render



17
18
19
20
21
22
23
24
# File 'app/helpers/hydra/blacklight_helper_behavior.rb', line 17

def type_field_to_partial_name(document, display_type)
  str = Array(display_type).join(' '.freeze).underscore
  if Rails.version >= '5.0.0'
    str.parameterize(separator: '_'.freeze)
  else
    str.parameterize('_'.freeze)
  end
end