Sha256: 2398fee62000e71ef97d330be0ea049efece6bb8bae5ddd14ae69af391d20597

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module ActionView
  class Template
    module Handlers
      class ERB
        class ThreadSafeErubi < Erubi
          def initialize(input, properties = {})
            @newline_pending = 0

            # Dup properties so that we don't modify argument
            properties = Hash[properties]
            properties[:preamble]   = "output_buffer = ActionView::OutputBuffer.new;"
            properties[:postamble]  = "output_buffer.to_s"
            properties[:bufvar]     = "output_buffer"
            properties[:escapefunc] = ""

            # Call ::Erubi::Engine#initializer
            method(__method__).super_method.super_method.call input, properties
          end

          private

          eval Erubi.instance_method(:add_text).source.gsub('@output_buffer', '#{@bufvar}')
          eval Erubi.instance_method(:add_expression).source.gsub('@output_buffer', '#{@bufvar}')
          eval Erubi.instance_method(:flush_newline_if_pending).source.gsub('@output_buffer', '#{@bufvar}')
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
async_partial-0.6.0 lib/async_partial/handlers/erubi.rb
async_partial-0.4.0 lib/async_partial/handlers/erubi.rb
async_partial-0.3.0 lib/async_partial/handlers/erubi.rb
async_partial-0.2.0 lib/async_partial/handlers/erubi.rb
async_partial-0.1.0 lib/async_partial/handlers/erubi.rb