lib/cjoiner/engines/jsjoiner.rb in cjoiner-1.5.2 vs lib/cjoiner/engines/jsjoiner.rb in cjoiner-1.6.0

- old
+ new

@@ -1,6 +1,29 @@ 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)