Sha256: b8e3b4d0dc15799e755a9880386d72c6a2eb84dee45e6dda6e8028f617130631

Contents?: true

Size: 894 Bytes

Versions: 20

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

20 entries across 20 versions & 1 rubygems

Version Path
actionview-5.1.7 lib/action_view/buffers.rb
actionview-5.1.7.rc1 lib/action_view/buffers.rb
actionview-5.1.6.2 lib/action_view/buffers.rb
actionview-5.1.6.1 lib/action_view/buffers.rb
actionview-5.1.6 lib/action_view/buffers.rb
actionview-5.1.5 lib/action_view/buffers.rb
actionview-5.1.5.rc1 lib/action_view/buffers.rb
actionview-5.1.4 lib/action_view/buffers.rb
actionview-5.1.4.rc1 lib/action_view/buffers.rb
actionview-5.1.3 lib/action_view/buffers.rb
actionview-5.1.3.rc3 lib/action_view/buffers.rb
actionview-5.1.3.rc2 lib/action_view/buffers.rb
actionview-5.1.3.rc1 lib/action_view/buffers.rb
actionview-5.1.2 lib/action_view/buffers.rb
actionview-5.1.2.rc1 lib/action_view/buffers.rb
actionview-5.1.1 lib/action_view/buffers.rb
actionview-5.1.0 lib/action_view/buffers.rb
actionview-5.1.0.rc2 lib/action_view/buffers.rb
actionview-5.1.0.rc1 lib/action_view/buffers.rb
actionview-5.1.0.beta1 lib/action_view/buffers.rb