lib/barista/compiler.rb in barista-1.2.1 vs lib/barista/compiler.rb in barista-1.3.0

- old
+ new

@@ -112,11 +112,11 @@ location = @options.fetch(:origin, 'inline') @compiled_content = compile(@context, location) @compiled_content = preamble(location) + @compiled_content if location != 'inline' && Barista.add_preamble? @compiled = true end - + def to_js compile! unless defined?(@compiled) && @compiled @compiled_content end @@ -157,10 +157,14 @@ protected def preamble(location) inner_message = copyable?(location) ? "copied" : "compiled" - "/* DO NOT MODIFY. This file was #{inner_message} #{Time.now.httpdate} from\n * #{location.strip}\n */\n\n" + if Barista.preamble + Barista.preamble.call(location) + else + "/* DO NOT MODIFY. This file was #{inner_message} #{Time.now.httpdate} from\n * #{location.strip}\n */\n\n" + end end def compilation_error_for(location, message) details = "Compilation of '#{location}' failed:\n#{message}" Barista.verbose? ? "alert(#{details.to_json});" : nil