Sha256: 80d41efc07d7f040e836526db81fa659af033ec4c3480eeb51e55e7cc4b600a9

Contents?: true

Size: 735 Bytes

Versions: 2

Compression:

Stored size: 735 Bytes

Contents

require 'eco'

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

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

    # Compile template data with Eco compiler.
    #
    # Returns a JS function definition String. The result should be
    # assigned to a JS variable.
    #
    #     # => "function(...) {...}"
    #
    def self.call(input)
      data = input[:data]
      input[:cache].fetch(cache_key + [data]) do
        ::Eco.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/eco_processor.rb
sprockets-3.0.0.beta.7 lib/sprockets/eco_processor.rb