Class: Tilt::StringTemplate

Inherits:
Template show all
Defined in:
lib/vendor/tilt-1.4.1/lib/tilt/string.rb

Overview

The template source is evaluated as a Ruby string. The #{} interpolation syntax can be used to generated dynamic output.

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

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

Instance Method Details

#precompiled(locals) ⇒ Object



16
17
18
19
# File 'lib/vendor/tilt-1.4.1/lib/tilt/string.rb', line 16

def precompiled(locals)
  source, offset = super
  [source, offset + 1]
end

#precompiled_template(locals) ⇒ Object



12
13
14
# File 'lib/vendor/tilt-1.4.1/lib/tilt/string.rb', line 12

def precompiled_template(locals)
  @code
end

#prepareObject



7
8
9
10
# File 'lib/vendor/tilt-1.4.1/lib/tilt/string.rb', line 7

def prepare
  hash = "TILT#{data.hash.abs}"
  @code = "<<#{hash}.chomp\n#{data}\n#{hash}"
end