Class: Tilt::StringTemplate

Inherits:
Template show all
Defined in:
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

#basename, 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

#precompiled(locals) ⇒ Object



16
17
18
19
# File '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/tilt/string.rb', line 12

def precompiled_template(locals)
  @code
end

#prepareObject



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

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