Class: Sprockets::SassTemplate
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Sprockets::SassTemplate
- Defined in:
- lib/sprockets/sass_template.rb
Overview
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.
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #evaluate(context, locals, &block) ⇒ Object
- #initialize_engine ⇒ Object
- #prepare ⇒ Object
- #syntax ⇒ Object
Class Method Details
.engine_initialized? ⇒ Boolean
12 13 14 |
# File 'lib/sprockets/sass_template.rb', line 12 def self.engine_initialized? defined? ::Sass::Engine end |
Instance Method Details
#evaluate(context, locals, &block) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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) = { :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, ).render rescue ::Sass::SyntaxError => e # Annotates exception message with parse line number context.__LINE__ = e.sass_backtrace.first[:line] raise e end |
#initialize_engine ⇒ Object
16 17 18 |
# File 'lib/sprockets/sass_template.rb', line 16 def initialize_engine require_template_library 'sass' end |
#prepare ⇒ Object
20 21 |
# File 'lib/sprockets/sass_template.rb', line 20 def prepare end |
#syntax ⇒ Object
23 24 25 |
# File 'lib/sprockets/sass_template.rb', line 23 def syntax :sass end |