class ActionView::OutputBuffer
:nodoc:
puts sbuf # => “hellou0005”
sbuf << 5
sbuf = ActiveSupport::SafeBuffer.new “hello”
puts obuf # => “hello5”
obuf << 5
obuf = ActionView::OutputBuffer.new “hello”
the input. For example:
checked for nil before they are assigned and ‘to_s` is called on
is for the methods `<<` and `safe_expr_append=` the inputs are
The main difference between this and ActiveSupport::SafeBuffer
Used as a buffer for views
def <<(value)
def <<(value) unless value.nil? value = value.to_s @raw_buffer << if value.html_safe? value else CGI.escapeHTML(value) end end self end
def ==(other)
def ==(other) other.class == self.class && @raw_buffer == other.to_str end
def capture(*args)
def capture(*args) new_buffer = +"" old_buffer, @raw_buffer = @raw_buffer, new_buffer yield(*args) new_buffer.html_safe ensure @raw_buffer = old_buffer end
def html_safe?
def html_safe? true end
def initialize(buffer = "")
puts sbuf # => "hello\u0005"
sbuf << 5
sbuf = ActiveSupport::SafeBuffer.new "hello"
puts obuf # => "hello5"
obuf << 5
obuf = ActionView::OutputBuffer.new "hello"
the input. For example:
checked for nil before they are assigned and `to_s` is called on
is for the methods `<<` and `safe_expr_append=` the inputs are
The main difference between this and ActiveSupport::SafeBuffer
Used as a buffer for views
def initialize(buffer = "") @raw_buffer = String.new(buffer) @raw_buffer.encode! end
def initialize_copy(other)
def initialize_copy(other) @raw_buffer = other.to_str end
def raw
def raw RawOutputBuffer.new(self) end
def safe_concat(value)
def safe_concat(value) @raw_buffer << value self end
def safe_expr_append=(val)
def safe_expr_append=(val) return self if val.nil? @raw_buffer << val.to_s self end
def to_s
def to_s @raw_buffer.html_safe end
def to_str
def to_str @raw_buffer.dup end