1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/lib/action_view/buffers.rb
Aaron Patterson 97ef636191 Stop nil checking on safe_append=
ERB compiler guarantees safe_append= will be called with a string, so
nil checks don't make sense.  Anything else calling this method should
check for nil themselves before calling
2014-09-14 13:26:39 -07:00

45 lines
797 B
Ruby

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= :<<
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