class Sprockets::EjsTemplate - sprockets-2.11.3 Documentation

# class Sprockets::EjsTemplate

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

For more infomation see:

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

### Public Class Methods

engine_initialized?() click to toggle source

Check to see if EJS is loaded

    # File lib/sprockets/ejs_template.rb, line 12
    def self.engine_initialized?
      defined? ::EJS
    end

### Public Instance Methods

evaluate(scope, locals, &block) click to toggle source

Compile template data with EJS compiler.

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

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

    # File lib/sprockets/ejs_template.rb, line 33
    def evaluate(scope, locals, &block)
      EJS.compile(data)
    end

initialize_engine() click to toggle source

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.

    # File lib/sprockets/ejs_template.rb, line 19
    def initialize_engine
      require_template_library 'ejs'
    end

prepare() click to toggle source

    # File lib/sprockets/ejs_template.rb, line 23
    def prepare
    end