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

precompiled(locals) click to toggle source
Calls superclass method Template#precompiled
   # File lib/tilt/erb.rb
56 def precompiled(locals)
57   source, offset = super
58   [source, offset + 1]
59 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
21 def prepare
22   @outvar = options[:outvar] || self.class.default_output_variable
23   options[:trim] = '<>' if !(options[:trim] == false) && (options[:trim].nil? || options[:trim] == true)
24   @engine = if SUPPORTS_KVARGS
25     ::ERB.new(data, trim_mode: options[:trim], eoutvar: @outvar)
26   else
27     ::ERB.new(data, options[:safe], options[:trim], @outvar)
28   end
29 end