Class: Twig::OutputBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/twig/output_buffer.rb

Instance Method Summary collapse

Constructor Details

#initializeOutputBuffer

Returns a new instance of OutputBuffer.



5
6
7
# File 'lib/twig/output_buffer.rb', line 5

def initialize
  @buffer = +''
end

Instance Method Details

#append=(string) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/twig/output_buffer.rb', line 9

def append=(string)
  unless string.nil?
    string = string.to_s

    @buffer << if string.html_safe?
                 string
               else
                 CGI.escapeHTML(string)
               end
  end
end

#safe_append=(string) ⇒ Object



21
22
23
# File 'lib/twig/output_buffer.rb', line 21

def safe_append=(string)
  @buffer << string.html_safe
end

#to_sObject



25
26
27
# File 'lib/twig/output_buffer.rb', line 25

def to_s
  @buffer
end