Repository: rails/rails
File: actionpack/lib/action_controller/metal/renderers.rb (Ruby)

Code before:
    Renderers.remove(key)
  end

  # See `Responder#api_behavior`
  class MissingRenderer < LoadError
    def initialize(format)
      super "No renderer defined for format: #{format}"
    end
  end

  module Renderers
    extend ActiveSupport::Concern

    # A Set containing renderer names that correspond to available renderer procs.
    # Default values are `:json`, `:js`, `:xml`.
    RENDERERS = Set.new

    included do
      class_attribute :_renderers, default: Set.new.freeze
      class_attribute :escape_json_responses, instance_accessor: false, default: true

      redefine_method :escape_json_responses= do |value|
        if value
          ActionController.deprecator.warn(<<~MSG.squish)
            Setting action_controller.escape_json_responses = true is deprecated and will have no effect in Rails 8.2.
            Set it to `false` or use `config.load_defaults(8.1)`.
          MSG
        end
        namespaced_name = :"__class_attr_escape_json_responses"
        self.class.send(:"#{namespaced_name}=", value)
      end

      class << self
        redefine_method :escape_json_responses= do |value|
          if value
            ActionController.deprecator.warn(<<~MSG.squish)
              Setting action_controller.escape_json_responses = true is deprecated and will have no effect in Rails 8.2.
              Set it to `false` or use `config.load_defaults(8.1)`.
            MSG
          end
          namespaced_name = :"__class_attr_escape_json_responses"
          self.send(:"#{namespaced_name}=", value)
        end
      end
    end

    # Used in ActionController::Base and ActionController::API to include all
    # renderers by default.
    module All
      extend ActiveSupport::Concern
      include Renderers

Review comment (suggestion):
wdyt about this? https://github.com/rails/rails/pull/54643#discussion_r2022206660

```suggestion
            Set it to `false`, or remove the config.
```

Code after:
    Renderers.remove(key)
  end

  # See `Responder#api_behavior`
  class MissingRenderer < LoadError
    def initialize(format)
      super "No renderer defined for format: #{format}"
    end
  end

  module Renderers
    extend ActiveSupport::Concern

    # A Set containing renderer names that correspond to available renderer procs.
    # Default values are `:json`, `:js`, `:xml`.
    RENDERERS = Set.new

    module DeprecatedEscapeJsonResponses # :nodoc:
      def escape_json_responses=(value)
        if value
          ActionController.deprecator.warn(<<~MSG.squish)
            Setting action_controller.escape_json_responses = true is deprecated and will have no effect in Rails 8.2.
            Set it to `false`, or remove the config.
          MSG
        end
        super
      end
    end

    included do
      class_attribute :_renderers, default: Set.new.freeze
      class_attribute :escape_json_responses, instance_writer: false, instance_accessor: false, default: true

      singleton_class.prepend DeprecatedEscapeJsonResponses
    end

    # Used in ActionController::Base and ActionController::API to include all
    # renderers by default.
    module All
      extend ActiveSupport::Concern
      include Renderers

      included do
        self._renderers = RENDERERS
      end
    end

    # Adds a new renderer to call within controller actions. A renderer is invoked
    # by passing its name as an option to AbstractController::Rendering#render. To
    # create a renderer pass it a name and a block. The block takes two arguments,
    # the first is the value paired with its key and the second is the remaining