File: engine.rb

package info (click to toggle)
ruby-js-image-paths 0.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 112 kB
  • sloc: ruby: 38; makefile: 3
file content (17 lines) | stat: -rw-r--r-- 625 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 |input|
        context = input[:environment].context_class.new(input)
        if context.logical_path == 'js_image_paths'
          JsImagePaths::Generator.context = context
        end
        {data: input[:data]}
      end
    end
  end
end