class Tilt::ERBTemplate
ERB template implementation. See: www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html
Constants
- SUPPORTS_KVARGS
Public Class Methods
Source
# File lib/tilt/erb.rb 13 def self._default_output_variable 14 @default_output_variable 15 end
Source
# File lib/tilt/erb.rb 16 def self.default_output_variable 17 warn "#{self}.default_output_variable is deprecated and will be removed in Tilt 2.3.", uplevel: 1 18 @default_output_variable 19 end
Source
# File lib/tilt/erb.rb 20 def self.default_output_variable=(name) 21 warn "#{self}.default_output_variable= is deprecated and will be removed in Tilt 2.3. Switch to using the :outvar option.", uplevel: 1 22 @default_output_variable = name 23 end
Public Instance Methods
Source
# File lib/tilt/erb.rb 74 def freeze_string_literals? 75 @freeze_string_literals 76 end
Source
# File lib/tilt/erb.rb 69 def precompiled(locals) 70 source, offset = super 71 [source, offset + 1] 72 end
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
Source
# File lib/tilt/erb.rb 58 def precompiled_postamble(locals) 59 <<-RUBY 60 #{super} 61 ensure 62 #{@outvar} = __original_outvar 63 end 64 RUBY 65 end
Source
# File lib/tilt/erb.rb 50 def precompiled_preamble(locals) 51 <<-RUBY 52 begin 53 __original_outvar = #{@outvar} if defined?(#{@outvar}) 54 #{super} 55 RUBY 56 end
Source
# File lib/tilt/erb.rb 45 def precompiled_template(locals) 46 source = @engine.src 47 source 48 end
Source
# File lib/tilt/erb.rb 25 def prepare 26 @freeze_string_literals = !!@options[:freeze] 27 @outvar = @options[:outvar] || self.class._default_output_variable || '_erbout' 28 trim = case @options[:trim] 29 when false 30 nil 31 when nil, true 32 '<>' 33 else 34 @options[:trim] 35 end 36 @engine = if SUPPORTS_KVARGS 37 ::ERB.new(@data, trim_mode: trim, eoutvar: @outvar) 38 # :nocov: 39 else 40 ::ERB.new(@data, options[:safe], trim, @outvar) 41 # :nocov: 42 end 43 end