class Tilt::ERBTemplate

ERB template implementation. See: www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html

Constants

SUPPORTS_KVARGS

Public Instance Methods

freeze_string_literals?() click to toggle source
   # File lib/tilt/erb.rb
60 def freeze_string_literals?
61   @freeze_string_literals
62 end
precompiled(locals) click to toggle source

ERB generates a line to specify the character coding of the generated source in 1.9. Account for this in the line offset.

Calls superclass method
   # File lib/tilt/erb.rb
55 def precompiled(locals)
56   source, offset = super
57   [source, offset + 1]
58 end
precompiled_postamble(locals) click to toggle source
   # File lib/tilt/erb.rb
44     def precompiled_postamble(locals)
45       <<-RUBY
46           #{super}
47         ensure
48           #{@outvar} = __original_outvar
49         end
50       RUBY
51     end
precompiled_preamble(locals) click to toggle source
   # File lib/tilt/erb.rb
36     def precompiled_preamble(locals)
37       <<-RUBY
38         begin
39           __original_outvar = #{@outvar} if defined?(#{@outvar})
40           #{super}
41       RUBY
42     end
precompiled_template(locals) click to toggle source
   # File lib/tilt/erb.rb
31 def precompiled_template(locals)
32   source = @engine.src
33   source
34 end
prepare() click to toggle source
   # File lib/tilt/erb.rb
11 def prepare
12   @freeze_string_literals = !!@options[:freeze]
13   @outvar = @options[:outvar] || '_erbout'
14   trim = case @options[:trim]
15   when false
16     nil
17   when nil, true
18     '<>'
19   else
20     @options[:trim]
21   end
22   @engine = if SUPPORTS_KVARGS
23     ::ERB.new(@data, trim_mode: trim, eoutvar: @outvar)
24   # :nocov:
25   else
26     ::ERB.new(@data, options[:safe], trim, @outvar)
27   # :nocov:
28   end
29 end