class Sprockets::SassTemplate
See ‘SassImporter` for more infomation.
with sprocket’s caching system.
main difference is that it uses a custom importer that plays nice
This custom Tilt handler replaces the one built into Tilt. The
def self.engine_initialized?
def self.engine_initialized? defined?(::Sass::Engine) && defined?(::Sass::Script::Functions) && ::Sass::Script::Functions < Sprockets::SassFunctions end
def evaluate(context, locals, &block)
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) }, :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
def initialize_engine
def initialize_engine # Double check constant to avoid tilt warning unless defined? ::Sass require_template_library 'sass' end # Install custom functions. It'd be great if this didn't need to # be installed globally, but could be passed into Engine as an # option. ::Sass::Script::Functions.send :include, Sprockets::SassFunctions end
def prepare
def prepare end
def syntax
def syntax :sass end