Module: Middleman::CoreExtensions::Sprockets
- Defined in:
- middleman-more/lib/middleman-more/core_extensions/sprockets.rb
Overview
Sprockets extension
Defined Under Namespace
Modules: InstanceMethods Classes: MiddlemanSprocketsEnvironment
Class Method Summary (collapse)
-
+ (Object) registered(app)
(also: included)
Once registered.
Class Method Details
+ (Object) registered(app) Also known as: included
Once registered
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'middleman-more/lib/middleman-more/core_extensions/sprockets.rb', line 11 def registered(app) # Add class methods to context app.send :include, InstanceMethods # Once Middleman is setup app.ready do # Add any gems with (vendor|app|.)/assets/javascripts to paths # also add similar directories from project root (like in rails) root_paths = [%w{ app }, %w{ assets }, %w{ vendor }, %w{ app assets }, %w{ vendor assets }, %w{ lib }, %w{ lib assets }] try_paths = root_paths.map {|rp| File.join(rp, 'javascripts') } + root_paths.map {|rp| File.join(rp, 'stylesheets') } ([root] + ::Middleman.rubygems_latest_specs.map(&:full_gem_path)).each do |root_path| try_paths.map {|p| File.join(root_path, p) }. select {|p| File.directory?(p) }. each {|path| sprockets.append_path(path) } end # Setup Sprockets Sass options sass.each { |k, v| ::Sprockets::Sass.[k] = v } # Intercept requests to /javascripts and /stylesheets and pass to sprockets our_sprockets = sprockets map("/#{js_dir}") { run our_sprockets } map("/#{css_dir}") { run our_sprockets } end end |