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(["info:fedora/hull-cModel:genericContent"])
=> 'generic_content'
type_field_to_partial_name(["info:fedora/hull-cModel: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
# File 'app/helpers/hydra/blacklight_helper_behavior.rb', line 17

def type_field_to_partial_name(document, display_type)
  Array(display_type).first.gsub(/^[^\/]+\/[^:]+:/,"").gsub("-","_").underscore.parameterize("_")
end