2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-17 04:44:24 +08:00
|
|
|
class SourceURL < Tilt::Template
|
|
|
|
self.default_mime_type = 'application/javascript'
|
|
|
|
|
2017-04-17 22:11:51 +08:00
|
|
|
def self.call(input)
|
|
|
|
filename = input[:filename]
|
|
|
|
source = input[:data]
|
|
|
|
context = input[:environment].context_class.new(input)
|
|
|
|
|
2017-07-28 09:20:09 +08:00
|
|
|
result = new(filename) { source }.render(context)
|
2017-04-17 22:11:51 +08:00
|
|
|
context.metadata.merge(data: result)
|
|
|
|
end
|
|
|
|
|
2015-04-17 04:44:24 +08:00
|
|
|
def prepare
|
|
|
|
end
|
|
|
|
|
|
|
|
def evaluate(scope, locals, &block)
|
2020-01-23 07:12:05 +08:00
|
|
|
"#{data.rstrip} //# sourceURL=#{scope.logical_path}\n\n"
|
2015-04-17 04:44:24 +08:00
|
|
|
end
|
|
|
|
end
|