diff --git a/app/presenters/blacklight/field_presenter.rb b/app/presenters/blacklight/field_presenter.rb index 8d4a63fece..50bbb619c2 100644 --- a/app/presenters/blacklight/field_presenter.rb +++ b/app/presenters/blacklight/field_presenter.rb @@ -3,6 +3,12 @@ module Blacklight # Renders a field and handles link_to_facet or helper_method if supplied class FieldPresenter + # @param controller [Object] the context in which to execute helper methods + # @param document [SolrDocument] the document + # @param field_config [Blacklight::Configuration::Field] the field's configuration + # @param options [Hash] + # @option options [Object] :value when this is provided, we don't want the pipeline to deal with helper methods. + # this happens when drawing the label for the document def initialize(controller, document, field_config, options) @controller = controller @document = document @@ -13,15 +19,12 @@ def initialize(controller, document, field_config, options) attr_reader :controller, :document, :field_config, :options def render - if options[:value] - # This prevents helper methods from drawing. - config = Configuration::NullField.new(field_config.to_h.except(:helper_method)) - values = Array.wrap(options[:value]) - else - config = field_config - values = retrieve_values - end - Rendering::Pipeline.render(values, config, document, controller, options) + return Rendering::Pipeline.render(retrieve_values, field_config, document, controller, options) unless options[:value] + + values = Array.wrap(options[:value]) + # Prevents helper methods from drawing. + steps = Rendering::Pipeline.operations - [Rendering::HelperMethod] + Rendering::Pipeline.new(values, field_config, document, controller, steps, options).render end private diff --git a/app/presenters/blacklight/index_presenter.rb b/app/presenters/blacklight/index_presenter.rb index 6776a47406..b5f65aaaa5 100644 --- a/app/presenters/blacklight/index_presenter.rb +++ b/app/presenters/blacklight/index_presenter.rb @@ -17,7 +17,8 @@ def initialize(document, view_context, configuration = view_context.blacklight_c end ## - # Render the document index heading + # 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. # # @param [Symbol, Proc, String] field_or_string_or_proc Render the given field or evaluate the proc or render the given string # @param [Hash] opts diff --git a/app/presenters/blacklight/rendering/pipeline.rb b/app/presenters/blacklight/rendering/pipeline.rb index cb9e5d100b..efea4646c9 100644 --- a/app/presenters/blacklight/rendering/pipeline.rb +++ b/app/presenters/blacklight/rendering/pipeline.rb @@ -3,7 +3,7 @@ module Blacklight module Rendering # The field rendering pipeline. - # This takes a field and it's values and transforms them through a list of + # This takes a field and its values and transforms them through a list of # operations. class Pipeline class_attribute :operations, instance_accessor: false @@ -14,7 +14,7 @@ class Pipeline # @param values [Array] the values for the field # @param config [Blacklight::Configuration::Field] the field's configuration # @param document [SolrDocument] the document - # @param context [Object] an execution context, used to execute the helper method in. + # @param context [Object] an execution context, used to execute the helper method in. # @param operations [Array] the list of operations in this Pipeline # @param options [Hash] options to pass to the processors. Typically only `:value` is used def initialize(values, config, document, context, operations, options)