Class: Sprockets::SassProcessor
- Inherits:
-
Object
- Object
- Sprockets::SassProcessor
- Defined in:
- lib/sprockets/sass_processor.rb,
lib/sprockets/sass_cache_store.rb
Overview
Processor engine class for the SASS/SCSS compiler. Depends on the ‘sass` gem.
For more infomation see:
https://github.com/sass/sass
https://github.com/rails/sass-rails
Direct Known Subclasses
Defined Under Namespace
Modules: Functions Classes: CacheStore
Instance Attribute Summary collapse
-
#cache_key ⇒ Object
readonly
Returns the value of attribute cache_key.
Class Method Summary collapse
- .cache_key ⇒ Object
- .call(input) ⇒ Object
-
.instance ⇒ Object
Public: Return singleton instance with default options.
-
.syntax ⇒ Object
Internal: Defines default sass syntax to use.
Instance Method Summary collapse
- #call(input) ⇒ Object
-
#initialize(options = {}, &block) ⇒ SassProcessor
constructor
Public: Initialize template with custom options.
Constructor Details
#initialize(options = {}, &block) ⇒ SassProcessor
Public: Initialize template with custom options.
options - Hash
cache_version - String custom cache version. Used to force a cache
change after code changes are made to Sass Functions.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sprockets/sass_processor.rb', line 45 def initialize( = {}, &block) @cache_version = [:cache_version] @cache_key = [ self.class.name, VERSION, Autoload::Sass::VERSION, @cache_version ].freeze @functions = Module.new do include Functions include [:functions] if [:functions] class_eval(&block) if block_given? end end |
Instance Attribute Details
#cache_key ⇒ Object (readonly)
Returns the value of attribute cache_key.
37 38 39 |
# File 'lib/sprockets/sass_processor.rb', line 37 def cache_key @cache_key end |
Class Method Details
.cache_key ⇒ Object
33 34 35 |
# File 'lib/sprockets/sass_processor.rb', line 33 def self.cache_key instance.cache_key end |
.call(input) ⇒ Object
29 30 31 |
# File 'lib/sprockets/sass_processor.rb', line 29 def self.call(input) instance.call(input) end |
.instance ⇒ Object
Public: Return singleton instance with default options.
Returns SassProcessor object.
25 26 27 |
# File 'lib/sprockets/sass_processor.rb', line 25 def self.instance @instance ||= new end |
.syntax ⇒ Object
Internal: Defines default sass syntax to use. Exposed so the ScssProcessor may override it.
18 19 20 |
# File 'lib/sprockets/sass_processor.rb', line 18 def self.syntax :sass end |
Instance Method Details
#call(input) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/sprockets/sass_processor.rb', line 61 def call(input) context = input[:environment].context_class.new(input) = { filename: input[:filename], syntax: self.class.syntax, cache_store: CacheStore.new(input[:cache], @cache_version), load_paths: input[:environment].paths, sprockets: { context: context, environment: input[:environment], dependencies: context.[:dependencies] } } engine = Autoload::Sass::Engine.new(input[:data], ) css = Utils.module_include(Autoload::Sass::Script::Functions, @functions) do engine.render end # Track all imported files sass_dependencies = Set.new([input[:filename]]) engine.dependencies.map do |dependency| sass_dependencies << dependency.[:filename] context.[:dependencies] << URIUtils.build_file_digest_uri(dependency.[:filename]) end context..merge(data: css, sass_dependencies: sass_dependencies) end |