Class: Temple::Templates::Tilt

Inherits:
Tilt::Template
  • Object
show all
Extended by:
Mixins::Template
Defined in:
lib/temple/templates/tilt.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Template

compile, create, register_as

Methods included from Mixins::ClassOptions

#default_options, #define_deprecated_options, #define_options, #disable_option_validator!, #options, #set_default_options, #set_options

Class Method Details

.register_as(*names) ⇒ Object



34
35
36
# File 'lib/temple/templates/tilt.rb', line 34

def self.register_as(*names)
  ::Tilt.register(self, *names.map(&:to_s))
end

Instance Method Details

#precompiled_template(locals = {}) ⇒ String

A string containing the (Ruby) source code for the template.

Parameters:

  • locals (Hash) (defaults to: {})

    Local variables

Returns:

  • (String)

    Compiled template ruby code



30
31
32
# File 'lib/temple/templates/tilt.rb', line 30

def precompiled_template(locals = {})
  @src
end

#preparevoid

This method returns an undefined value.

Prepare Temple template

Called immediately after template data is loaded.



16
17
18
19
20
21
22
23
24
# File 'lib/temple/templates/tilt.rb', line 16

def prepare
  opts = {}.update(self.class.options).update(options).update(file: eval_file)
  [:mime_type] = opts.delete(:mime_type)
  if opts.include?(:outvar)
    opts[:buffer] = opts.delete(:outvar)
    opts[:save_buffer] = true
  end
  @src = self.class.compile(data, opts)
end