mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:54:59 +08:00
24 lines
530 B
Ruby
24 lines
530 B
Ruby
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)
|
|
code = "eval("
|
|
code << data.inspect
|
|
code << " + \"\\n//# sourceURL=#{scope.logical_path}\""
|
|
code << ");\n"
|
|
code
|
|
end
|
|
end
|