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, line 12
def self.default_output_variable
  @@default_output_variable
end
default_output_variable=(name) click to toggle source
# File lib/tilt/erb.rb, line 16
def self.default_output_variable=(name)
  warn "#{self}.default_output_variable= has been replaced with the :outvar-option"
  @@default_output_variable = name
end

Public Instance Methods

precompiled(locals) click to toggle source
Calls superclass method Template#precompiled
# File lib/tilt/erb.rb, line 56
def precompiled(locals)
  source, offset = super
  [source, offset + 1]
end
precompiled_postamble(locals) click to toggle source
# File lib/tilt/erb.rb, line 44
    def precompiled_postamble(locals)
      <<-RUBY
          #{super}
        ensure
          #{@outvar} = __original_outvar
        end
      RUBY
    end
precompiled_preamble(locals) click to toggle source
# File lib/tilt/erb.rb, line 36
    def precompiled_preamble(locals)
      <<-RUBY
        begin
          __original_outvar = #{@outvar} if defined?(#{@outvar})
          #{super}
      RUBY
    end
precompiled_template(locals) click to toggle source
# File lib/tilt/erb.rb, line 31
def precompiled_template(locals)
  source = @engine.src
  source
end
prepare() click to toggle source
# File lib/tilt/erb.rb, line 21
def prepare
  @outvar = options[:outvar] || self.class.default_output_variable
  options[:trim] = '<>' if !(options[:trim] == false) && (options[:trim].nil? || options[:trim] == true)
  @engine = if SUPPORTS_KVARGS
    ::ERB.new(data, trim_mode: options[:trim], eoutvar: @outvar)
  else
    ::ERB.new(data, options[:safe], options[:trim], @outvar)
  end
end