Sha256: f67c963c6b355921101e23cd26a8dc1b0d637610750810ce2ce2c92b1634c9ea

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

require 'sprockets/component_processor'

class Rafters::Engine < Rails::Engine
  isolate_namespace Rafters

  config.generators do |g|
    g.test_framework :rspec
    g.assets false
    g.helper false
  end

  initializer "rafters.load_view_paths" do |app|
    Rafters.view_paths = Dir[app.root.join("app", "components", "*", "views")]
  end

  initializer "rafters.load_asset_paths" do |app|
    Rafters.asset_paths = Dir[app.root.join("app", "components", "*", "assets", "*")]
  end

  initializer "rafters.set_asset_paths", :after => "rafters.load_asset_paths" do |app|
    app.config.assets.paths += Rafters.asset_paths
  end

  initializer "rafters.set_autoload_paths", :before => :set_autoload_paths do |app|
    app.config.autoload_paths += Dir[app.root.join("app", "components", "*/")]
  end

  config.after_initialize do |app|
    begin
      app.assets.unregister_preprocessor('text/css', Sprockets::DirectiveProcessor)
      app.assets.register_preprocessor('text/css', Sprockets::ComponentProcessor)
    rescue
      Rails.logger.warn("Could not load Sprockets::ComponentProcessor for text/css")
    end

    begin
      app.assets.unregister_preprocessor('application/javascript', Sprockets::DirectiveProcessor)
      app.assets.register_preprocessor('application/javascript', Sprockets::ComponentProcessor)
    rescue
      Rails.logger.warn("Could not load Sprockets::ComponentProcessor for application/javascript")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rafters-0.0.3 lib/rafters/engine.rb