Module: Sprockets::EjsProcessor

Defined in:
lib/sprockets/ejs_processor.rb

Overview

Processor engine class for the EJS compiler. Depends on the `ejs` gem.

For more infomation see:

https://github.com/sstephenson/ruby-ejs

Constant Summary collapse

VERSION =
'1'

Class Method Summary collapse

Class Method Details

.call(input) ⇒ Object

Compile template data with EJS compiler.

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

# => "function(obj){...}"


20
21
22
23
24
25
26
# File 'lib/sprockets/ejs_processor.rb', line 20

def self.call(input)
  data = input[:data]
  key  = [self.name, VERSION, data]
  input[:cache].fetch(key) do
    ::EJS.compile(data)
  end
end