Sha256: 930834584dea52b65cd5c4cc46d814659b4cef2e3a29c4e66fd89fc0e5c1f0c7

Contents?: true

Size: 846 Bytes

Versions: 21

Compression:

Stored size: 846 Bytes

Contents

# frozen_string_literal: true

# :markup: markdown

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

21 entries across 21 versions & 2 rubygems

Version Path
actiontext-8.0.1 lib/action_text/rendering.rb
actiontext-8.0.0.1 lib/action_text/rendering.rb
actiontext-7.2.2.1 lib/action_text/rendering.rb
actiontext-8.0.0 lib/action_text/rendering.rb
actiontext-7.2.2 lib/action_text/rendering.rb
actiontext-8.0.0.rc2 lib/action_text/rendering.rb
actiontext-7.2.1.2 lib/action_text/rendering.rb
actiontext-8.0.0.rc1 lib/action_text/rendering.rb
actiontext-7.2.1.1 lib/action_text/rendering.rb
actiontext-8.0.0.beta1 lib/action_text/rendering.rb
omg-actiontext-8.0.0.alpha9 lib/action_text/rendering.rb
omg-actiontext-8.0.0.alpha8 lib/action_text/rendering.rb
omg-actiontext-8.0.0.alpha7 lib/action_text/rendering.rb
omg-actiontext-8.0.0.alpha4 lib/action_text/rendering.rb
omg-actiontext-8.0.0.alpha3 lib/action_text/rendering.rb
actiontext-7.2.1 lib/action_text/rendering.rb
actiontext-7.2.0 lib/action_text/rendering.rb
actiontext-7.2.0.rc1 lib/action_text/rendering.rb
actiontext-7.2.0.beta3 lib/action_text/rendering.rb
actiontext-7.2.0.beta2 lib/action_text/rendering.rb