Class: Tilt::ERBTemplate
Overview
Constant Summary
collapse
- @@default_output_variable =
'_erbout'
Instance Attribute Summary
Attributes inherited from Template
#data, #file, #line, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Template
#allows_script?, #basename, #default_encoding, #eval_file, #initialize, #name, #read_template_file, #render
Constructor Details
This class inherits a constructor from Tilt::Template
Class Method Details
.default_output_variable ⇒ Object
9
10
11
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 9
def self.default_output_variable
@@default_output_variable
end
|
.default_output_variable=(name) ⇒ Object
13
14
15
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 13
def self.default_output_variable=(name)
@@default_output_variable = name
end
|
.engine_initialized? ⇒ Boolean
17
18
19
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 17
def self.engine_initialized?
defined? ::ERB
end
|
Instance Method Details
#initialize_engine ⇒ Object
21
22
23
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 21
def initialize_engine
require_template_library 'erb'
end
|
#precompiled(locals) ⇒ Object
56
57
58
59
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 56
def precompiled(locals)
source, offset = super
[source, offset + 1]
end
|
#precompiled_postamble(locals) ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 44
def precompiled_postamble(locals)
<<-RUBY
#{super}
ensure
#{@outvar} = __original_outvar
end
RUBY
end
|
#precompiled_preamble(locals) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 36
def precompiled_preamble(locals)
<<-RUBY
begin
__original_outvar = #{@outvar} if defined?(#{@outvar})
#{super}
RUBY
end
|
#precompiled_template(locals) ⇒ Object
31
32
33
34
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 31
def precompiled_template(locals)
source = @engine.src
source
end
|
25
26
27
28
29
|
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 25
def prepare
@outvar = options[:outvar] || self.class.default_output_variable
options[:trim] = '<>' if !(options[:trim] == false) && (options[:trim].nil? || options[:trim] == true)
@engine = ::ERB.new(data, options[:safe], options[:trim], @outvar)
end
|