Sha256: 9bf4bbe6c2973af03592c250eaed8e5486c5555b211aaba95938b6ce43e80763

Contents?: true

Size: 825 Bytes

Versions: 18

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"
require "active_support/core_ext/module/attribute_accessors_per_thread"

module ActionText
  module Rendering # :nodoc:
    extend ActiveSupport::Concern

    included do
      thread_cattr_accessor :renderer, instance_accessor: false
      delegate :render, to: :class
    end

    class_methods do
      def action_controller_renderer
        @action_controller_renderer ||= Class.new(ActionController::Base).renderer
      end

      def with_renderer(renderer)
        previous_renderer = self.renderer
        self.renderer = renderer
        yield
      ensure
        self.renderer = previous_renderer
      end

      def render(*args, &block)
        (renderer || action_controller_renderer).render_to_string(*args, &block)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 4 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/actiontext-7.1.3.4/lib/action_text/rendering.rb
actiontext-7.1.5.1 lib/action_text/rendering.rb
actiontext-7.1.5 lib/action_text/rendering.rb
actiontext-7.1.4.2 lib/action_text/rendering.rb
actiontext-7.1.4.1 lib/action_text/rendering.rb
actiontext-7.1.4 lib/action_text/rendering.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actiontext-7.1.3.4/lib/action_text/rendering.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/actiontext-7.1.3.4/lib/action_text/rendering.rb
actiontext-7.1.3.4 lib/action_text/rendering.rb
actiontext-7.1.3.2 lib/action_text/rendering.rb
actiontext-7.1.3.1 lib/action_text/rendering.rb
actiontext-7.1.3 lib/action_text/rendering.rb
actiontext-7.1.2 lib/action_text/rendering.rb
actiontext-7.1.1 lib/action_text/rendering.rb
actiontext-7.1.0 lib/action_text/rendering.rb
actiontext-7.1.0.rc2 lib/action_text/rendering.rb
actiontext-7.1.0.rc1 lib/action_text/rendering.rb
actiontext-7.1.0.beta1 lib/action_text/rendering.rb