Sha256: cf940c0d3cb74664c350df9e79675f98aca6a5e6faeb9fcfd12dfa4180b885bb

Contents?: true

Size: 887 Bytes

Versions: 2

Compression:

Stored size: 887 Bytes

Contents

module LiveScript
  module Rails
    module SprocketsProcessor
      def self.cache_key
        @cache_key ||= "#{name}:#{LiveScript::Source::VERSION}:#{LiveScript::VERSION}:#{LiveScript::Rails::VERSION}".freeze
      end

      def self.call(input)
        data = input[:data]
        options = {
          bare: true,
          header: false,
          map: 'linked-src',
          filename: input[:source_path] || input[:filename],
        }.merge(::Rails.application.config.assets.livescript || {})

        result = input[:cache].fetch([self.cache_key, data]) do
          LiveScript.compile(data, options)
        end

        # when map: none, result is String; otherwise, result is Hash
        if result.kind_of? Hash
          {
            data: result['code'],
            map: result['map'],
          }
        else
          result
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
livescript-rails-2.0.1 lib/livescript/rails/processor.rb
livescript-rails-2.0.0 lib/livescript/rails/processor.rb