Class: Blacklight::IndexPresenter

Inherits:
DocumentPresenter show all
Defined in:
app/presenters/blacklight/index_presenter.rb

Instance Attribute Summary

Attributes inherited from DocumentPresenter

#configuration, #document, #view_context

Instance Method Summary collapse

Methods inherited from DocumentPresenter

#display_type, #field_presenters, #field_value, #fields_to_render, #heading, #html_title, #initialize, #inspect, #link_rel_alternates, #show_view_config, #thumbnail, #thumbnail_presenter_class

Constructor Details

This class inherits a constructor from Blacklight::DocumentPresenter

Instance Method Details

#label(field_or_string_or_proc, opts = {}) ⇒ Object

Render the document index heading. This is used when making a link to a document, where we don't want any HTML markup added from the pipeline.

Parameters:

  • field_or_string_or_proc (Symbol, Proc, String)

    Render the given field or evaluate the proc or render the given string

  • opts (Hash) (defaults to: {})


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/presenters/blacklight/index_presenter.rb', line 10

def label(field_or_string_or_proc, opts = {})
  config = Configuration::NullField.new
  value = case field_or_string_or_proc
            when Symbol
              config = field_config(field_or_string_or_proc)
              field_presenter(config).values
            when Proc
              Deprecation.warn(self, "calling IndexPresenter.label with a Proc is deprecated. " \
                                     "First argument must be a symbol. This will be removed in Blacklight 8")
              field_or_string_or_proc.call(document, opts)
            when String
              Deprecation.warn(self, "calling IndexPresenter.label with a String is deprecated. " \
                                     "First argument must be a symbol. This will be removed in Blacklight 8")
              field_or_string_or_proc
          end

  value = document.id if value.blank?
  field_value(config, values: Array.wrap(value), except_operations: [Rendering::HelperMethod])
end

#view_configObject



32
33
34
# File 'app/presenters/blacklight/index_presenter.rb', line 32

def view_config
  @view_config ||= configuration.view_config(view_context.document_index_view_type)
end