Sha256: b040330d5e74c8f50b81cc7f01707b322fd41faee012c9840ce77ce7a63b84fc

Contents?: true

Size: 749 Bytes

Versions: 38

Compression:

Stored size: 749 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
      cattr_accessor :default_renderer, instance_accessor: false
      thread_cattr_accessor :renderer, instance_accessor: false
      delegate :render, to: :class
    end

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

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

Version data entries

38 entries across 36 versions & 4 rubygems

Version Path
actiontext-7.0.8.7 lib/action_text/rendering.rb
actiontext-7.0.8.6 lib/action_text/rendering.rb
actiontext-7.0.8.5 lib/action_text/rendering.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.8.4/lib/action_text/rendering.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/actiontext-7.0.5.1/lib/action_text/rendering.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/actiontext-7.0.5.1/lib/action_text/rendering.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/actiontext-7.0.5.1/lib/action_text/rendering.rb
actiontext-7.0.8.4 lib/action_text/rendering.rb
actiontext-7.0.8.1 lib/action_text/rendering.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actiontext-7.0.3.1/lib/action_text/rendering.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actiontext-7.0.2.3/lib/action_text/rendering.rb
actiontext-7.0.8 lib/action_text/rendering.rb
actiontext-7.0.7.2 lib/action_text/rendering.rb
actiontext-7.0.7.1 lib/action_text/rendering.rb
actiontext-7.0.7 lib/action_text/rendering.rb
actiontext-7.0.6 lib/action_text/rendering.rb
actiontext-7.0.5.1 lib/action_text/rendering.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actiontext-7.0.2.3/lib/action_text/rendering.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actiontext-7.0.3.1/lib/action_text/rendering.rb
actiontext-7.0.5 lib/action_text/rendering.rb