Class: Tilt::ERBTemplate
Constant Summary
collapse
- SUPPORTS_KVARGS =
::ERB.instance_method(:initialize).parameters.assoc(:key) rescue false
Instance Attribute Summary
Attributes inherited from Template
#compiled_path, #data, #file, #line, #options
Instance Method Summary
collapse
Methods inherited from Template
#basename, #compiled_method, default_mime_type, default_mime_type=, #eval_file, #fixed_locals?, #initialize, #metadata, metadata, #name, #render
Constructor Details
This class inherits a constructor from Tilt::Template
Instance Method Details
#freeze_string_literals? ⇒ Boolean
125
126
127
|
# File 'lib/tilt/erb.rb', line 125
def freeze_string_literals?
@freeze_string_literals
end
|
#precompiled(locals) ⇒ Object
ERB generates a line to specify the character coding of the generated source in 1.9. Account for this in the line offset.
120
121
122
123
|
# File 'lib/tilt/erb.rb', line 120
def precompiled(locals)
source, offset = super
[source, offset + 1]
end
|
#precompiled_postamble(locals) ⇒ Object
109
110
111
112
113
114
115
116
|
# File 'lib/tilt/erb.rb', line 109
def precompiled_postamble(locals)
" \#{super}\n ensure\n \#{@outvar} = __original_outvar\n end\n RUBY\nend\n"
|
#precompiled_preamble(locals) ⇒ Object
101
102
103
104
105
106
107
|
# File 'lib/tilt/erb.rb', line 101
def precompiled_preamble(locals)
" begin\n __original_outvar = \#{@outvar} if defined?(\#{@outvar})\n \#{super}\n RUBY\nend\n"
|
#precompiled_template(locals) ⇒ Object
96
97
98
99
|
# File 'lib/tilt/erb.rb', line 96
def precompiled_template(locals)
source = @engine.src
source
end
|
#prepare ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/tilt/erb.rb', line 76
def prepare
@freeze_string_literals = !!@options[:freeze]
@outvar = @options[:outvar] || '_erbout'
trim = case @options[:trim]
when false
nil
when nil, true
'<>'
else
@options[:trim]
end
@engine = if SUPPORTS_KVARGS
::ERB.new(@data, trim_mode: trim, eoutvar: @outvar)
else
::ERB.new(@data, options[:safe], trim, @outvar)
end
end
|