Class: JRB::Template

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/jrb/template.rb

Instance Method Summary collapse

Instance Method Details

#precompiled_postamble(locals) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/jrb/template.rb', line 27

def precompiled_postamble(locals)
  <<-RUBY
    ensure
      #{@buffer_variable} = __old_output_buffer
    end
    __output_buffer << __result unless __result == __output_buffer
    __output_buffer
  RUBY
end

#precompiled_preamble(locals) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jrb/template.rb', line 12

def precompiled_preamble(locals)
  <<-RUBY
    #{super}
    __output_buffer = #{@new_buffer}
    __old_output_buffer, #{@buffer_variable} = #{@buffer_variable}, __output_buffer
    instance_eval do
      def <<(data)
        #{@buffer_variable} << data
      end
      alias write <<
    end
    __result = begin
  RUBY
end

#precompiled_template(locals) ⇒ Object



37
38
39
# File 'lib/jrb/template.rb', line 37

def precompiled_template(locals)
  data.to_str
end

#prepareObject



7
8
9
10
# File 'lib/jrb/template.rb', line 7

def prepare
  @buffer_variable = "@output_buffer" # Rails compatibility with capture()
  @new_buffer = options.delete(:escape_html) == false ? "''" : "ActiveSupport::SafeBuffer.new"
end