Sha256: f2bec61e2e7364d648921b54488b8f5051aac4de6a0a4e95f197bfd476b7e872
Contents?: true
Size: 1.21 KB
Versions: 8
Compression:
Stored size: 1.21 KB
Contents
require 'tilt' module Sprockets # 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. class SassTemplate < Tilt::Template self.default_mime_type = 'text/css' def self.engine_initialized? defined? ::Sass::Engine end def initialize_engine require_template_library 'sass' end def prepare end def syntax :sass end 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 end end
Version data entries
8 entries across 8 versions & 1 rubygems