mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
bc4c40abd4
- Refactor source_url to avoid using eval in development - Precompile handlebars in development - Include template compilers when running qunit - Remove unsafe-eval in development CSP - Include unsafe-eval only for qunit routes in development
25 lines
573 B
Ruby
25 lines
573 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)
|
|
code = +"\n//# BEGIN sourceURL=#{scope.logical_path}\n"
|
|
code << data
|
|
code << "\n//# END sourceURL=#{scope.logical_path}\n"
|
|
code
|
|
end
|
|
end
|