class Tilt::ERBTemplate

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

Constants

SUPPORTS_KVARGS

Public Class Methods

default_output_variable() click to toggle source
   # File lib/tilt/erb.rb
12 def self.default_output_variable
13   @@default_output_variable
14 end
default_output_variable=(name) click to toggle source
   # File lib/tilt/erb.rb
16 def self.default_output_variable=(name)
17   warn "#{self}.default_output_variable= has been replaced with the :outvar-option"
18   @@default_output_variable = name
19 end

Public Instance Methods

freeze_string_literals?() click to toggle source
   # File lib/tilt/erb.rb
68 def freeze_string_literals?
69   @freeze_string_literals
70 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
63 def precompiled(locals)
64   source, offset = super
65   [source, offset + 1]
66 end
precompiled_postamble(locals) click to toggle source
   # File lib/tilt/erb.rb
52     def precompiled_postamble(locals)
53       <<-RUBY
54           #{super}
55         ensure
56           #{@outvar} = __original_outvar
57         end
58       RUBY
59     end
precompiled_preamble(locals) click to toggle source
   # File lib/tilt/erb.rb
44     def precompiled_preamble(locals)
45       <<-RUBY
46         begin
47           __original_outvar = #{@outvar} if defined?(#{@outvar})
48           #{super}
49       RUBY
50     end
precompiled_template(locals) click to toggle source
   # File lib/tilt/erb.rb
39 def precompiled_template(locals)
40   source = @engine.src
41   source
42 end
prepare() click to toggle source
   # File lib/tilt/erb.rb
21 def prepare
22   @freeze_string_literals = !!@options[:freeze]
23   @outvar = options[:outvar] || self.class.default_output_variable
24   trim = case options[:trim]
25   when false
26     nil
27   when nil, true
28     '<>'
29   else
30     options[:trim]
31   end
32   @engine = if SUPPORTS_KVARGS
33     ::ERB.new(data, trim_mode: trim, eoutvar: @outvar)
34   else
35     ::ERB.new(data, options[:safe], trim, @outvar)
36   end
37 end