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