Class: Underscore::Template
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Underscore::Template
- Defined in:
- lib/underscore-template/template.rb
Overview
Tilt engine class for the Underscore compiler.
Class Method Summary collapse
-
.engine_initialized? ⇒ Boolean
Check to see if Underscore is loaded.
Instance Method Summary collapse
-
#evaluate(scope, locals, &block) ⇒ Object
Compile template data with Underscore compiler.
-
#initialize_engine ⇒ Object
Autoload underscore-template library.
- #prepare ⇒ Object
Class Method Details
.engine_initialized? ⇒ Boolean
Check to see if Underscore is loaded
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_engine ⇒ Object
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 |
#prepare ⇒ Object
19 20 |
# File 'lib/underscore-template/template.rb', line 19 def prepare end |