Class: Sprockets::SasscProcessor
- Inherits:
-
Object
- Object
- Sprockets::SasscProcessor
- Defined in:
- lib/sprockets/sassc_processor.rb
Overview
Processor engine class for the SASS/SCSS compiler. Depends on the ‘sassc` gem.
For more information see:
https://github.com/sass/sassc-ruby
https://github.com/sass/sassc-rails
Direct Known Subclasses
Defined Under Namespace
Modules: Functions
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) ⇒ SasscProcessor
constructor
A new instance of SasscProcessor.
Constructor Details
#initialize(options = {}, &block) ⇒ SasscProcessor
Returns a new instance of SasscProcessor.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sprockets/sassc_processor.rb', line 40 def initialize( = {}, &block) @cache_version = [:cache_version] @cache_key = "#{self.class.name}:#{VERSION}:#{Autoload::SassC::VERSION}:#{@cache_version}".freeze @importer_class = [:importer] @sass_config = [:sass_config] || {} @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.
38 39 40 |
# File 'lib/sprockets/sassc_processor.rb', line 38 def cache_key @cache_key end |
Class Method Details
.cache_key ⇒ Object
34 35 36 |
# File 'lib/sprockets/sassc_processor.rb', line 34 def self.cache_key instance.cache_key end |
.call(input) ⇒ Object
30 31 32 |
# File 'lib/sprockets/sassc_processor.rb', line 30 def self.call(input) instance.call(input) end |
.instance ⇒ Object
Public: Return singleton instance with default options.
Returns SasscProcessor object.
26 27 28 |
# File 'lib/sprockets/sassc_processor.rb', line 26 def self.instance @instance ||= new end |
.syntax ⇒ Object
Internal: Defines default sass syntax to use. Exposed so the ScsscProcessor may override it.
19 20 21 |
# File 'lib/sprockets/sassc_processor.rb', line 19 def self.syntax :sass end |
Instance Method Details
#call(input) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/sprockets/sassc_processor.rb', line 52 def call(input) context = input[:environment].context_class.new(input) = (input, context) engine = Autoload::SassC::Engine.new(input[:data], ) css = Utils.module_include(Autoload::SassC::Script::Functions, @functions) do engine.render.sub(/^\n^\/\*# sourceMappingURL=.*\*\/$/m, '') end begin map = SourceMapUtils.format_source_map(JSON.parse(engine.source_map), input) map = SourceMapUtils.combine_source_maps(input[:metadata][:map], map) engine.dependencies.each do |dependency| context.[:dependencies] << URIUtils.build_file_digest_uri(dependency.filename) end rescue SassC::NotRenderedError map = input[:metadata][:map] end context..merge(data: css, map: map) end |