Class: Sprockets::SassTemplate

### Home Classes Methods

### In Files

- lib/sprockets/sass_cache_store.rb
- lib/sprockets/sass_processor.rb

### Parent

Object

### Namespace

- MODULE Sprockets::SassProcessor::Functions
- CLASS Sprockets::SassProcessor::CacheStore

### Methods

- ::cache_key
- ::call
- ::instance
- ::new
- ::syntax
- #call

### Included Modules

- Sprockets::SassProcessor::Functions

### Class/Module Index

Quicksearch

- Sprockets
- Sprockets::ArgumentError
- Sprockets::Asset
- Sprockets::Autoload
- Sprockets::Base
- Sprockets::Bower
- Sprockets::Bundle
- Sprockets::Cache
- Sprockets::Cache::FileStore
- Sprockets::Cache::GetWrapper
- Sprockets::Cache::HashWrapper
- Sprockets::Cache::MemoryStore
- Sprockets::Cache::NullStore
- Sprockets::Cache::ReadWriteWrapper
- Sprockets::Cache::Wrapper
- Sprockets::CachedEnvironment
- Sprockets::ClosureCompressor
- Sprockets::CoffeeScriptProcessor
- Sprockets::CoffeeScriptTemplate
- Sprockets::Compressing
- Sprockets::Configuration
- Sprockets::ContentTypeMismatch
- Sprockets::Context
- Sprockets::ConversionError
- Sprockets::Dependencies
- Sprockets::DigestUtils
- Sprockets::DirectiveProcessor
- Sprockets::ERBProcessor
- Sprockets::ERBTemplate
- Sprockets::EcoProcessor
- Sprockets::EcoTemplate
- Sprockets::EjsProcessor
- Sprockets::EjsTemplate
- Sprockets::EncodingUtils
- Sprockets::Engines
- Sprockets::Environment
- Sprockets::Error
- Sprockets::FileNotFound
- Sprockets::FileOutsidePaths
- Sprockets::FileReader
- Sprockets::HTTPUtils
- Sprockets::Index
- Sprockets::JstProcessor
- Sprockets::LegacyProcProcessor
- Sprockets::LegacyTiltProcessor
- Sprockets::Loader
- Sprockets::Manifest
- Sprockets::ManifestUtils
- Sprockets::Mime
- Sprockets::NotFound
- Sprockets::NotImplementedError
- Sprockets::PathDependencyUtils
- Sprockets::PathDigestUtils
- Sprockets::PathUtils
- Sprockets::Paths
- Sprockets::Processing
- Sprockets::ProcessorUtils
- Sprockets::Resolve
- Sprockets::SassCompressor
- Sprockets::SassProcessor
- Sprockets::SassProcessor::CacheStore
- Sprockets::SassProcessor::Functions
- Sprockets::SassTemplate
- Sprockets::ScssProcessor
- Sprockets::ScssTemplate
- Sprockets::Server
- Sprockets::Transformers
- Sprockets::URITar
- Sprockets::URIUtils
- Sprockets::UglifierCompressor
- Sprockets::UnloadedAsset
- Sprockets::Utils
- Sprockets::YUICompressor
- Rake
- Rake::SprocketsTask

No matching classes.

# Sprockets::SassTemplate

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

### Attributes

cache_key[R]

### Public Class Methods

cache_key() click to toggle source

    # File lib/sprockets/sass_processor.rb, line 33
    def self.cache_key
      instance.cache_key
    end

call(input) click to toggle source

    # File lib/sprockets/sass_processor.rb, line 29
    def self.call(input)
      instance.call(input)
    end

instance() click to toggle source

Public: Return singleton instance with default options.

Returns SassProcessor object.

    # File lib/sprockets/sass_processor.rb, line 25
    def self.instance
      @instance ||= new
    end

new(options = {}, &block) click to toggle source

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.

    # File lib/sprockets/sass_processor.rb, line 45
    def initialize(options = {}, &block)
      @cache_version = options[:cache_version]
      @cache_key = "#{self.class.name}:#{VERSION}:#{Autoload::Sass::VERSION}:#{@cache_version}".freeze

      @functions = Module.new do
        include Functions
        include options[:functions] if options[:functions]
        class_eval(&block) if block_given?
      end
    end

syntax() click to toggle source

Internal: Defines default sass syntax to use. Exposed so the ScssProcessor may override it.

    # File lib/sprockets/sass_processor.rb, line 18
    def self.syntax
      :sass
    end

### Public Instance Methods

call(input) click to toggle source

    # File lib/sprockets/sass_processor.rb, line 56
    def call(input)
      context = input[:environment].context_class.new(input)

      options = {
        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.metadata[:dependencies]
        }
      }

      engine = Autoload::Sass::Engine.new(input[:data], options)

      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.options[:filename]
        context.metadata[:dependencies] << URIUtils.build_file_digest_uri(dependency.options[:filename])
      end

      context.metadata.merge(data: css, sass_dependencies: sass_dependencies)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.