mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Update SourceURL to work better
This commit is contained in:
parent
e83bf7dc07
commit
788b66e4a3
4 changed files with 18 additions and 3 deletions
|
@ -1,3 +1,5 @@
|
|||
require 'discourse_iife'
|
||||
require 'source_url'
|
||||
|
||||
Rails.application.assets.register_preprocessor('application/javascript', DiscourseIIFE)
|
||||
Rails.application.assets.register_postprocessor('application/javascript', SourceURL)
|
||||
|
|
|
@ -32,7 +32,6 @@ class DiscourseIIFE < Sprockets::Processor
|
|||
.sub("/app/assets/javascripts", "")
|
||||
.sub("/test/javascripts", "")
|
||||
res << "\nwindow.__jshintSrc = window.__jshintSrc || {}; window.__jshintSrc['/assets#{req_path}'] = #{data.to_json};\n"
|
||||
res << "\n//@ sourceURL=/#{context.logical_path}\n"
|
||||
end
|
||||
|
||||
res
|
||||
|
|
|
@ -127,7 +127,6 @@ module Tilt
|
|||
req_path = "/assets/#{scope.logical_path}.#{extension}"
|
||||
|
||||
@output << "\nwindow.__jshintSrc = window.__jshintSrc || {}; window.__jshintSrc['#{req_path}'] = #{data.to_json};\n"
|
||||
@output << "\n//@ sourceURL=/#{scope.logical_path}\n"
|
||||
end
|
||||
|
||||
@output
|
||||
|
|
15
lib/source_url.rb
Normal file
15
lib/source_url.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
class SourceURL < Tilt::Template
|
||||
self.default_mime_type = 'application/javascript'
|
||||
|
||||
def prepare
|
||||
end
|
||||
|
||||
def evaluate(scope, locals, &block)
|
||||
code = ''
|
||||
code << 'eval('
|
||||
code << data.inspect
|
||||
code << " + \"\\n//@ sourceURL=/#{scope.logical_path}\""
|
||||
code << ");\n"
|
||||
code
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue