Class: Astro::Middleware::Sprockets

Inherits:
Object
  • Object
show all
Defined in:
lib/astro/middleware/sprockets.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Sprockets

Returns a new instance of Sprockets.



7
8
9
# File 'lib/astro/middleware/sprockets.rb', line 7

def initialize( app )
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Creates a new sprockets environment instance and adds an anonymous preprocessor to require dependencies from the ‘astro.assets` array.



15
16
17
18
19
20
21
22
23
# File 'lib/astro/middleware/sprockets.rb', line 15

def call( env )
  sprockets = ::Sprockets::Environment.new
  sprockets.append_path 'lib/assets/javascripts'
  sprockets.append_path 'lib/assets/stylesheets'

  env[ 'astro.sprockets' ] = sprockets

  @app.call env
end