Parent

Sprockets::SassTemplate

This custom Tilt handler replaces the one built into Tilt. The main difference is that it uses a custom importer that plays nice with sprocket's caching system.

See `SassImporter` for more infomation.

Public Class Methods

engine_initialized?() click to toggle source
# File lib/sprockets/sass_template.rb, line 12
def self.engine_initialized?
  defined? ::Sass::Engine
end

Public Instance Methods

evaluate(context, locals, &block) click to toggle source
# File lib/sprockets/sass_template.rb, line 27
def evaluate(context, locals, &block)
  # Use custom importer that knows about Sprockets Caching
  cache_store = SassCacheStore.new(context.environment)

  options = {
    :filename => eval_file,
    :line => line,
    :syntax => syntax,
    :cache_store => cache_store,
    :importer => SassImporter.new(context, context.pathname),
    :load_paths => context.environment.paths.map { |path| SassImporter.new(context, path) }
  }

  ::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
initialize_engine() click to toggle source
# File lib/sprockets/sass_template.rb, line 16
def initialize_engine
  require_template_library 'sass'
end
prepare() click to toggle source
# File lib/sprockets/sass_template.rb, line 20
def prepare
end
syntax() click to toggle source
# File lib/sprockets/sass_template.rb, line 23
def syntax
  :sass
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.