Class: Tilt::ERBTemplate
Overview
ERB template implementation. See: www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html
Direct Known Subclasses
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
- #freeze_string_literals? ⇒ Boolean
-
#precompiled(locals) ⇒ Object
ERB generates a line to specify the character coding of the generated source in 1.9.
- #precompiled_postamble(locals) ⇒ Object
- #precompiled_preamble(locals) ⇒ Object
- #precompiled_template(locals) ⇒ Object
- #prepare ⇒ Object
Methods inherited from Template
#basename, #compiled_method, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render
Constructor Details
This class inherits a constructor from Tilt::Template
Instance Method Details
#freeze_string_literals? ⇒ Boolean
60 61 62 |
# File 'lib/tilt/erb.rb', line 60 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.
55 56 57 58 |
# File 'lib/tilt/erb.rb', line 55 def precompiled(locals) source, offset = super [source, offset + 1] end |
#precompiled_postamble(locals) ⇒ Object
44 45 46 47 48 49 50 51 |
# File '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/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/tilt/erb.rb', line 31 def precompiled_template(locals) source = @engine.src source end |
#prepare ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tilt/erb.rb', line 11 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) # :nocov: else ::ERB.new(@data, [:safe], trim, @outvar) # :nocov: end end |