Sha256: c4c423b33916395a78ab485aa6e50c65242c81270e296e10b36a814496ae7115

Contents?: true

Size: 894 Bytes

Versions: 86

Compression:

Stored size: 894 Bytes

Contents

require 'active_support/core_ext/string/output_safety'

module ActionView
  class OutputBuffer < ActiveSupport::SafeBuffer #:nodoc:
    def initialize(*)
      super
      encode!
    end

    def <<(value)
      return self if value.nil?
      super(value.to_s)
    end
    alias :append= :<<

    def safe_expr_append=(val)
      return self if val.nil?
      safe_concat val.to_s
    end

    alias :safe_append= :safe_concat
  end

  class StreamingBuffer #:nodoc:
    def initialize(block)
      @block = block
    end

    def <<(value)
      value = value.to_s
      value = ERB::Util.h(value) unless value.html_safe?
      @block.call(value)
    end
    alias :concat  :<<
    alias :append= :<<

    def safe_concat(value)
      @block.call(value.to_s)
    end
    alias :safe_append= :safe_concat

    def html_safe?
      true
    end

    def html_safe
      self
    end
  end
end

Version data entries

86 entries across 84 versions & 10 rubygems

Version Path
actionview-4.2.5.rc2 lib/action_view/buffers.rb
actionview-4.2.5.rc1 lib/action_view/buffers.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/actionview-4.2.4/lib/action_view/buffers.rb
actionview-4.2.4 lib/action_view/buffers.rb
actionview-4.2.4.rc1 lib/action_view/buffers.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/actionview-4.2.3/lib/action_view/buffers.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/actionview-4.2.3/lib/action_view/buffers.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/actionview-4.2.2/lib/action_view/buffers.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/actionview-4.2.1/lib/action_view/buffers.rb
actionview-4.2.3 lib/action_view/buffers.rb
actionview-4.2.3.rc1 lib/action_view/buffers.rb
actionview-4.2.2 lib/action_view/buffers.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_view/buffers.rb
actionview-4.2.1 lib/action_view/buffers.rb
actionview-4.2.1.rc4 lib/action_view/buffers.rb
actionview-4.2.1.rc3 lib/action_view/buffers.rb
actionview-4.2.1.rc2 lib/action_view/buffers.rb
actionview-4.2.1.rc1 lib/action_view/buffers.rb
activejob-lock-0.0.1 rails/actionview/lib/action_view/buffers.rb
actionview-4.2.0 lib/action_view/buffers.rb