mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:50:00 +08:00
57390d0bb9
The `sourceURL` directive must be on the same line as the thing it's referencing. This patch allows it to work again in development mode because each Javascript file ends up in its own `define(...)` line. It will strip out any trailing whitespace and put the `sourceURL` comment on the same line and everything seems to work.
22 lines
490 B
Ruby
22 lines
490 B
Ruby
# frozen_string_literal: true
|
|
|
|
class SourceURL < Tilt::Template
|
|
self.default_mime_type = 'application/javascript'
|
|
|
|
def self.call(input)
|
|
filename = input[:filename]
|
|
source = input[:data]
|
|
context = input[:environment].context_class.new(input)
|
|
|
|
result = new(filename) { source }.render(context)
|
|
context.metadata.merge(data: result)
|
|
end
|
|
|
|
def prepare
|
|
end
|
|
|
|
def evaluate(scope, locals, &block)
|
|
"#{data.rstrip} //# sourceURL=#{scope.logical_path}\n\n"
|
|
end
|
|
end
|