Class: Sprockets::SassTemplate

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/compass-rails/patches/sass_importer.rb

Instance Method Summary collapse

Instance Method Details

#evaluate(context, locals, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/compass-rails/patches/sass_importer.rb', line 3

def evaluate(context, locals, &block)
  # Use custom importer that knows about Sprockets Caching
  cache_store = SassCacheStore.new(context.environment)
  paths  = context.environment.paths.map { |path| CompassRails::SpriteImporter.new(context, path) }
  paths += context.environment.paths.map { |path| SassImporter.new(context, path) }
  paths += ::Rails.application.config.sass.load_paths


  options = CompassRails.sass_config.merge( {
    :filename => eval_file,
    :line => line,
    :syntax => syntax,
    :cache_store => cache_store,
    :importer => SassImporter.new(context, context.pathname),
    :load_paths => paths,
    :sprockets => {
      :context => context,
      :environment => context.environment
    }
  })

  ::Sass::Engine.new(data, options).render
rescue ::Sass::SyntaxError => e
  # Annotates exception message with parse line number
  context.__LINE__ = e.sass_backtrace.first[:line]
  raise e
end