aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/safe_buffer.rb
blob: 6be05b9e1ed0c909fb0de10ea48f4e701c3df1d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module ActionView #:nodoc:
  class SafeBuffer < String
    def <<(value)
      if value.html_safe?
        super(value)
      else
        super(ERB::Util.h(value))
      end
    end

    def concat(value)
      self << value
    end

    def html_safe?
      true
    end

    def html_safe!
      self
    end

    def to_s
      self
    end
  end
end