lib/barista/compiler.rb in barista-0.7.0.pre2 vs lib/barista/compiler.rb in barista-0.7.0.pre3
- old
+ new
@@ -88,11 +88,11 @@
end
def compile!
location = @options.fetch(:origin, 'inline')
@compiled_content = compile(@context, location)
- @compiled_content = preamble(location) + @compiled_content if Barista.add_preamble?
+ @compiled_content = preamble(location) + @compiled_content if location != 'inline' && Barista.add_preamble?
@compiled = true
end
def to_js
compile! unless defined?(@compiled) && @compiled
@@ -105,10 +105,15 @@
Barista.invoke_hook :compiled, where
out
rescue CoffeeScript::Error => e
Barista.invoke_hook :compilation_failed, where, e.message
if Barista.exception_on_error? && !@options[:silence]
- raise CompilationError, "CoffeeScript encountered an error compiling #{where}: #{e.message}"
+ if e.is_a?(CoffeeScript::CompilationError)
+ where_within_app = where.sub(/#{Regexp.escape(Barista.app_root.to_s)}\/?/, '')
+ raise CompilationError, "Error: In #{where_within_app}, #{e.message}"
+ else
+ raise CompilationError, "CoffeeScript encountered an error compiling #{where}: #{e.message}"
+ end
end
compilation_error_for where, e.message
end
def save(path = @options[:output_path])