Sha256: 90c654b90c506876a4fba45c2fc5a355325fa928d449c45041b4a16c425db0db

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

require 'rafters/directive_processor'

class Rafters::Railtie < Rails::Railtie
  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', Rafters::DirectiveProcessor)
    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', Rafters::DirectiveProcessor)
    rescue
      Rails.logger.warn("Could not load Sprockets::ComponentProcessor for application/javascript")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rafters-0.1.3 lib/rafters/railtie.rb
rafters-0.1.2 lib/rafters/railtie.rb
rafters-0.1.1 lib/rafters/railtie.rb