Inversion::
TiltWrapper
class
An adapter class for Tilt (github.com/rtomayko/tilt) :todo: Add an example or two.
Tilt::Template API: returns true if Inversion is loaded.
def self::engine_initialized?
return defined?( Inversion::Template )
end
evaluate( scope, locals, &block )
Tilt::Template API: render the template with the given ‘scope`, `locals`, and `block`.
def evaluate( scope, locals, &block )
@template.attributes.merge!( scope.to_h ) if scope.respond_to?( :to_h )
@template.attributes.merge!( locals )
return @template.render( &block )
end
Tilt::Template API: lazy-load Inversion
def initialize_engine
require_template_library 'inversion'
end
Tilt::Template API: load a template
def prepare
@template = Inversion::Template.new( self.data, self.options )
@template.source_file = self.file
end
Hook the template’s render phase.
def render( *args )
self.evaluate( *args )
end