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 information see:

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

Constant Summary collapse

VERSION =
'1'

Class Method Summary collapse

Class Method Details

.cache_keyObject



14
15
16
# File 'lib/sprockets/ejs_processor.rb', line 14

def self.cache_key
  @cache_key ||= "#{name}:#{VERSION}".freeze
end

.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){...}"


25
26
27
28
29
30
# File 'lib/sprockets/ejs_processor.rb', line 25

def self.call(input)
  data = input[:data]
  input[:cache].fetch([cache_key, data]) do
    Autoload::EJS.compile(data)
  end
end