Class: Sprockets::EcoTemplate
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Sprockets::EcoTemplate
- Defined in:
- lib/sprockets/eco_template.rb
Overview
Tilt engine class for the Eco compiler. Depends on the ‘eco` gem.
For more infomation see:
https://github.com/sstephenson/ruby-eco
https://github.com/sstephenson/eco
Class Method Summary collapse
-
.engine_initialized? ⇒ Boolean
Check to see if Eco is loaded.
Instance Method Summary collapse
-
#evaluate(scope, locals, &block) ⇒ Object
Compile template data with Eco compiler.
-
#initialize_engine ⇒ Object
Autoload eco library.
- #prepare ⇒ Object
Class Method Details
.engine_initialized? ⇒ Boolean
Check to see if Eco is loaded
13 14 15 |
# File 'lib/sprockets/eco_template.rb', line 13 def self.engine_initialized? defined? ::Eco end |
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
Compile template data with Eco compiler.
Returns a JS function definition String. The result should be assigned to a JS variable.
# => "function(...) {...}"
34 35 36 |
# File 'lib/sprockets/eco_template.rb', line 34 def evaluate(scope, locals, &block) Eco.compile(data) end |
#initialize_engine ⇒ Object
Autoload eco library. If the library isn’t loaded, Tilt will produce a thread safetly warning. If you intend to use ‘.eco` files, you should explicitly require it.
20 21 22 |
# File 'lib/sprockets/eco_template.rb', line 20 def initialize_engine require_template_library 'eco' end |
#prepare ⇒ Object
24 25 |
# File 'lib/sprockets/eco_template.rb', line 24 def prepare end |