class Inversion::TiltWrapper
An adapter class for Tilt (github.com/rtomayko/tilt) :todo: Add an example or two.
Public Class Methods
engine_initialized?()
click to toggle source
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
evaluate( scope, locals, &block )
click to toggle source
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
initialize_engine()
click to toggle source
Tilt::Template API: lazy-load Inversion
# File lib/inversion/tilt.rb, line 19 def initialize_engine require_template_library 'inversion' end
prepare()
click to toggle source
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
render( *args )
click to toggle source
Hook the template’s render phase.
# File lib/inversion/tilt.rb, line 33 def render( *args ) self.evaluate( *args ) end