Sha256: 009b9cd37772f8be5e53a281c1415b0e0ca4774cc047d13efe397773ca44bd3a

Contents?: true

Size: 669 Bytes

Versions: 2

Compression:

Stored size: 669 Bytes

Contents

require 'ejs'

module Sprockets
  # Processor engine class for the EJS compiler. Depends on the `ejs` gem.
  #
  # For more infomation see:
  #
  #   https://github.com/sstephenson/ruby-ejs
  #
  module EjsProcessor
    VERSION = '1'

    def self.cache_key
      @cache_key ||= [name, VERSION].freeze
    end

    # Compile template data with EJS compiler.
    #
    # Returns a JS function definition String. The result should be
    # assigned to a JS variable.
    #
    #     # => "function(obj){...}"
    #
    def self.call(input)
      data = input[:data]
      input[:cache].fetch(cache_key + [data]) do
        ::EJS.compile(data)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sprockets-3.0.0.beta.8 lib/sprockets/ejs_processor.rb
sprockets-3.0.0.beta.7 lib/sprockets/ejs_processor.rb