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
#basename, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render
Constructor Details
This class inherits a constructor from Tilt::Template
Class Method Details
.default_output_variable ⇒ Object
10
11
12
|
# File 'lib/tilt/erb.rb', line 10
def self.default_output_variable
@@default_output_variable
end
|
.default_output_variable=(name) ⇒ Object
14
15
16
17
|
# File 'lib/tilt/erb.rb', line 14
def self.default_output_variable=(name)
warn "#{self}.default_output_variable= has been replaced with the :outvar-option"
@@default_output_variable = name
end
|
Instance Method Details
#precompiled(locals) ⇒ Object
50
51
52
53
|
# File 'lib/tilt/erb.rb', line 50
def precompiled(locals)
source, offset = super
[source, offset + 1]
end
|
#precompiled_postamble(locals) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/tilt/erb.rb', line 38
def precompiled_postamble(locals)
<<-RUBY
#{super}
ensure
#{@outvar} = __original_outvar
end
RUBY
end
|
#precompiled_preamble(locals) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/tilt/erb.rb', line 30
def precompiled_preamble(locals)
<<-RUBY
begin
__original_outvar = #{@outvar} if defined?(#{@outvar})
#{super}
RUBY
end
|
#precompiled_template(locals) ⇒ Object
25
26
27
28
|
# File 'lib/tilt/erb.rb', line 25
def precompiled_template(locals)
source = @engine.src
source
end
|
#prepare ⇒ Object
19
20
21
22
23
|
# File 'lib/tilt/erb.rb', line 19
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
|