File: engine.rb

package info (click to toggle)
ruby-js-image-paths 0.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 100 kB
  • ctags: 10
  • sloc: ruby: 37; makefile: 2
file content (16 lines) | stat: -rw-r--r-- 554 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module JsImagePaths
  class Engine < Rails::Engine
    config.root = '/usr/share/ruby-js-image-paths'
    isolate_namespace(JsImagePaths)

    initializer('js_image_paths.compile', after: 'sprockets.environment') do |application|
      sprockets_env = application.assets || Sprockets
      sprockets_env.register_preprocessor('application/javascript', :'js_image_path.compile') do |context, data|
        if context.logical_path == 'js_image_paths'
          JsImagePaths::Generator.context = context
        end
        data
      end
    end
  end
end