TiltWrapper

class
Superclass
Tilt::Template

An adapter class for Tilt (github.com/rtomayko/tilt) :todo: Add an example or two.

Public Class Methods

anchor
engine_initialized?()

Tilt::Template API: returns true if Inversion is loaded.

# File lib/inversion/tilt.rb, line 13
def self::engine_initialized?
        return defined?( Inversion::Template )
end

Public Instance Methods

anchor
evaluate( scope, locals, &block )

Tilt::Template API: render the template with the given scope, locals, and block.

# File lib/inversion/tilt.rb, line 38
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
anchor
initialize_engine()

Tilt::Template API: lazy-load Inversion

# File lib/inversion/tilt.rb, line 19
def initialize_engine
        require_template_library 'inversion'
end
anchor
prepare()

Tilt::Template API: load a template

# File lib/inversion/tilt.rb, line 25
def prepare
        # Load the instance and set the path to the source
        @template = Inversion::Template.new( self.data, self.options )
        @template.source_file = self.file
end
anchor
render( *args )

Hook the template's render phase.

# File lib/inversion/tilt.rb, line 33
def render( *args )
        self.evaluate( *args )
end