Module: Middleman::CoreExtensions::Compass

Defined in:
lib/middleman-more/core_extensions/compass.rb

Overview

Forward the settings on config.rb and the result of registered extensions to Compass

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object Also known as: included

Once registered



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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/middleman-more/core_extensions/compass.rb', line 12

def registered(app)
  # Require the library
  require "compass"

  # Hooks to manually update the compass config after we're
  # done with it
  app.define_hook :compass_config

  # Location of SASS/SCSS files external to source directory.
  # @return [Array]
  #   set :sass_assets_paths, ["#{root}/assets/sass/", "/path/2/external/sass/repository/"]
  app.set :sass_assets_paths, []

  app.after_configuration do
    ::Compass.configuration do |config|
      config.project_path    = source_dir
      config.environment     = :development
      config.cache_path      = sass_cache_path
      config.sass_dir        = css_dir
      config.additional_import_paths = sass_assets_paths
      config.css_dir         = css_dir
      config.javascripts_dir = js_dir
      config.fonts_dir       = fonts_dir
      config.images_dir      = images_dir
      config.http_path       = http_prefix

      # Disable this initially, the cache_buster extension will
      # re-enable it if requested.
      config.asset_cache_buster :none

      # Disable this initially, the relative_assets extension will
      # re-enable it if requested.
      config.relative_assets = false

      # Default output style
      config.output_style = :nested

      # No line-comments in test mode (changing paths mess with sha1)
      config.line_comments = false if ENV["TEST"]

      if respond_to?(:asset_host) && asset_host.is_a?(Proc)
        config.asset_host(&asset_host)
      end
    end

    # Call hook
    run_hook :compass_config, ::Compass.configuration

    # Tell Tilt to use it as well (for inline sass blocks)
    ::Tilt.register 'sass', CompassSassTemplate
    ::Tilt.prefer(CompassSassTemplate)

    # Tell Tilt to use it as well (for inline scss blocks)
    ::Tilt.register 'scss', CompassScssTemplate
    ::Tilt.prefer(CompassScssTemplate)
  end
end