Class: Underscore::Template

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/underscore-template/template.rb

Overview

Tilt engine class for the Underscore compiler.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.engine_initialized?Boolean

Check to see if Underscore is loaded

Returns:

  • (Boolean)


8
9
10
# File 'lib/underscore-template/template.rb', line 8

def self.engine_initialized?
  defined? ::Underscore::Engine
end

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object

Compile template data with Underscore compiler.

Returns a JS function definition String. The result should be assigned to a JS variable.

# => "_.template(...)"


29
30
31
# File 'lib/underscore-template/template.rb', line 29

def evaluate(scope, locals, &block)
  Underscore::Engine.compile(data)
end

#initialize_engineObject

Autoload underscore-template library. If the library isn’t loaded, Tilt will produce a thread safetly warning. If you intend to use ‘._` files, you should explicitly require it.



15
16
17
# File 'lib/underscore-template/template.rb', line 15

def initialize_engine
  require_template_library 'underscore-template'
end

#prepareObject



19
20
# File 'lib/underscore-template/template.rb', line 19

def prepare
end