class Tilt::ERBTemplate

  1. lib/tilt/erb.rb
Superclass: Template

Constants

SUPPORTS_KVARGS = ::ERB.instance_method(:initialize).parameters.assoc(:key) rescue false  

Public Instance methods

freeze_string_literals?()
[show source]
    # File lib/tilt/erb.rb
125 def freeze_string_literals?
126   @freeze_string_literals
127 end
precompiled(locals)

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

[show source]
    # File lib/tilt/erb.rb
120 def precompiled(locals)
121   source, offset = super
122   [source, offset + 1]
123 end
precompiled_postamble(locals)
[show source]
    # File lib/tilt/erb.rb
109     def precompiled_postamble(locals)
110       <<-RUBY
111           #{super}
112         ensure
113           #{@outvar} = __original_outvar
114         end
115       RUBY
116     end
precompiled_preamble(locals)
[show source]
    # File lib/tilt/erb.rb
101     def precompiled_preamble(locals)
102       <<-RUBY
103         begin
104           __original_outvar = #{@outvar} if defined?(#{@outvar})
105           #{super}
106       RUBY
107     end
precompiled_template(locals)
[show source]
   # File lib/tilt/erb.rb
96 def precompiled_template(locals)
97   source = @engine.src
98   source
99 end
prepare()
[show source]
   # File lib/tilt/erb.rb
76 def prepare
77   @freeze_string_literals = !!@options[:freeze]
78   @outvar = @options[:outvar] || '_erbout'
79   trim = case @options[:trim]
80   when false
81     nil
82   when nil, true
83     '<>'
84   else
85     @options[:trim]
86   end
87   @engine = if SUPPORTS_KVARGS
88     ::ERB.new(@data, trim_mode: trim, eoutvar: @outvar)
89   # :nocov:
90   else
91     ::ERB.new(@data, options[:safe], trim, @outvar)
92   # :nocov:
93   end
94 end