Class: Inversion::TiltWrapper
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Inversion::TiltWrapper
- Defined in:
- lib/inversion/tilt.rb
Overview
An adapter class for Tilt (github.com/rtomayko/tilt) :TODO: Add an example or two.
Class Method Summary collapse
-
.engine_initialized? ⇒ Boolean
Tilt::Template API: returns true if Inversion is loaded.
Instance Method Summary collapse
-
#evaluate(scope, locals, &block) ⇒ Object
Tilt::Template API: render the template with the given ‘scope`, `locals`, and `block`.
-
#initialize_engine ⇒ Object
Tilt::Template API: lazy-load Inversion.
-
#prepare ⇒ Object
Tilt::Template API: load a template.
-
#render(*args) ⇒ Object
Hook the template’s render phase.
Class Method Details
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
Tilt::Template API: render the template with the given ‘scope`, `locals`, and `block`.
39 40 41 42 43 44 |
# File 'lib/inversion/tilt.rb', line 39 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 ⇒ Object
Tilt::Template API: lazy-load Inversion
20 21 22 |
# File 'lib/inversion/tilt.rb', line 20 def initialize_engine require_template_library 'inversion' end |
#prepare ⇒ Object
Tilt::Template API: load a template
26 27 28 29 30 |
# File 'lib/inversion/tilt.rb', line 26 def prepare # Load the instance and set the path to the source @template = Inversion::Template.new( self.data, self. ) @template.source_file = self.file end |
#render(*args) ⇒ Object
Hook the template’s render phase.
34 35 36 |
# File 'lib/inversion/tilt.rb', line 34 def render( *args ) self.evaluate( *args ) end |