Sha256: 3b2594644bf7e2cc6f36291ff4caecb4b3e7e8ddcdac3e68f0678e2a1821fd5d

Contents?: true

Size: 966 Bytes

Versions: 2

Compression:

Stored size: 966 Bytes

Contents

require 'sprockets'

#NOTE: underscore.js interpolation hash(<%=(.*?)%>) conflicts with Sprockets
#      and raises UndefinedConstantError.
#
#     In order to avoid this behavior I just avoid the raise statement
#     and always return the value

module Sprockets
  class SourceLine
    protected
      def interpolate_constants!(result, constants)
        result.gsub!(/<%=(.*?)%>/) do
          constant = $1.strip
          if value = constants[constant]
            value
          else
            puts "WARNING: couldn't find constant `#{constant}' in #{inspect}"
            "<%=#{constant}%>"
          end
        end
      end
  end
end

module Cjoiner
  module Engines
    # engine for js files
    class JsJoiner < Cjoiner::Engines::Engine
      def initialize(opts)
        @engine = ::Sprockets::Secretary.new(
          :load_path    => opts[:paths],
          :source_files => opts[:sources]
        ).concatenation.to_s
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cjoiner-1.6.1 lib/cjoiner/engines/jsjoiner.rb
cjoiner-1.6.0 lib/cjoiner/engines/jsjoiner.rb