Class: Sprockets::SasscProcessor
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
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:
Class Method Summary
- .cache_key
- .call(input)
-
.instance
Public: Return singleton instance with default options.
- .new(options = {}, &block) ⇒ SasscProcessor constructor
-
.syntax
Internal: Defines default sass syntax to use.
Instance Attribute Summary
- #cache_key readonly
Instance Method Summary
Constructor Details
.new(options = {}, &block) ⇒ SasscProcessor
# 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
Class Method Details
.cache_key
[ GitHub ]# File 'lib/sprockets/sassc_processor.rb', line 34
def self.cache_key instance.cache_key end
.call(input)
[ GitHub ]# File 'lib/sprockets/sassc_processor.rb', line 30
def self.call(input) instance.call(input) end
.instance
Public: Return singleton instance with default options.
Returns SasscProcessor object.
# File 'lib/sprockets/sassc_processor.rb', line 26
def self.instance @instance ||= new end
.syntax
Internal: Defines default sass syntax to use. Exposed so the ScsscProcessor
may override it.
# File 'lib/sprockets/sassc_processor.rb', line 19
def self.syntax :sass end
Instance Attribute Details
#cache_key (readonly)
[ GitHub ]# File 'lib/sprockets/sassc_processor.rb', line 38
attr_reader :cache_key
Instance Method Details
#call(input)
[ GitHub ]# 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[: ][:map], map) engine.dependencies.each do |dependency| context. [:dependencies] << URIUtils.build_file_digest_uri(dependency.filename) end rescue SassC::NotRenderedError map = input[: ][:map] end context. .merge(data: css, map: map) end
#engine_options(input, context)
[ GitHub ]# File 'lib/sprockets/sassc_processor.rb', line 273
def (input, context) ({ filename: input[:filename], syntax: self.class.syntax, load_paths: input[:environment].paths, importer: @importer_class, source_map_contents: false, source_map_file: "#{input[:filename]}.map", omit_source_map_url: true, sprockets: { context: context, environment: input[:environment], dependencies: context. [:dependencies] } }) end
#merge_options(options) (private)
[ GitHub ]# File 'lib/sprockets/sassc_processor.rb', line 78
def ( ) defaults = @sass_config.dup if load_paths = defaults.delete(:load_paths) [:load_paths] += load_paths end .merge!(defaults) end