Class: Hyrax::PresenterRenderer

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TranslationHelper
Defined in:
app/presenters/hyrax/presenter_renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(presenter, view_context) ⇒ PresenterRenderer

Returns a new instance of PresenterRenderer.


6
7
8
9
# File 'app/presenters/hyrax/presenter_renderer.rb', line 6

def initialize(presenter, view_context)
  @presenter = presenter
  @view_context = view_context
end

Instance Method Details

#fields(terms, &_block) ⇒ Object

Deprecated.

27
28
29
30
# File 'app/presenters/hyrax/presenter_renderer.rb', line 27

def fields(terms, &_block)
  Deprecation.warn("Fields is deprecated for removal in Hyrax 4.0.0. use #value and #label directly instead.")
  @view_context.safe_join(terms.map { |term| yield self, term })
end

#label(field) ⇒ Object


19
20
21
22
23
# File 'app/presenters/hyrax/presenter_renderer.rb', line 19

def label(field)
  t(:"#{model_name.param_key}.#{field}",
    scope: label_scope,
    default: [:"defaults.#{field}", field.to_s.humanize]).presence
end

#value(field_name, locals = {}) ⇒ ActiveSupport::SafeBuffer

Renders a collection field partial

Returns:

  • (ActiveSupport::SafeBuffer)

    an html safe string containing the value markup


15
16
17
# File 'app/presenters/hyrax/presenter_renderer.rb', line 15

def value(field_name, locals = {})
  render_show_field_partial(field_name, locals)
end