Class: Tilt::StringTemplate
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
#compiled_path, #data, #file, #line, #options
Instance Method Summary collapse
- #freeze_string_literals? ⇒ Boolean
- #precompiled(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
23 24 25 |
# File 'lib/tilt/string.rb', line 23 def freeze_string_literals? @freeze_string_literals end |
#precompiled(locals) ⇒ Object
18 19 20 21 |
# File 'lib/tilt/string.rb', line 18 def precompiled(locals) source, offset = super [source, offset + 1] end |
#precompiled_template(locals) ⇒ Object
14 15 16 |
# File 'lib/tilt/string.rb', line 14 def precompiled_template(locals) @code end |
#prepare ⇒ Object
8 9 10 11 12 |
# File 'lib/tilt/string.rb', line 8 def prepare hash = "TILT#{@data.hash.abs}" @freeze_string_literals = !!@options[:freeze] @code = String.new("<<#{hash}.chomp\n#{@data}\n#{hash}") end |