Module: Sprockets::Engines

### Home Classes Methods

### In Files

- lib/sprockets/engines.rb

### Methods

- #engine_extensions
- #engines
- #register_engine

### Class/Module Index

Quicksearch

- Sprockets
- Sprockets::ArgumentError
- Sprockets::Asset
- Sprockets::AssetAttributes
- Sprockets::Base
- Sprockets::BundledAsset
- Sprockets::Cache
- Sprockets::Cache::FileStore
- Sprockets::Caching
- Sprockets::CharsetNormalizer
- Sprockets::CircularDependencyError
- Sprockets::ContentTypeMismatch
- Sprockets::Context
- Sprockets::DirectiveProcessor
- Sprockets::EcoTemplate
- Sprockets::EjsTemplate
- Sprockets::EncodingError
- Sprockets::EngineError
- Sprockets::Engines
- Sprockets::Environment
- Sprockets::Error
- Sprockets::FileNotFound
- Sprockets::FileOutsidePaths
- Sprockets::Index
- Sprockets::JstProcessor
- Sprockets::Manifest
- Sprockets::Mime
- Sprockets::ProcessedAsset
- Sprockets::ProcessedAsset::DependencyFile
- Sprockets::Processing
- Sprockets::Processor
- Sprockets::SafetyColons
- Sprockets::Server
- Sprockets::StaticAsset
- Sprockets::Trail
- Sprockets::UnserializeError
- Sprockets::Utils
- Rake
- Rake::SprocketsTask

No matching classes.

# Sprockets::Engines

`Engines` provides a global and `Environment` instance registry.

An engine is a type of processor that is bound to an filename extension. `application.js.coffee` indicates that the `CoffeeScriptTemplate` engine will be ran on the file.

Extensions can be stacked and will be evaulated from right to left. `application.js.coffee.erb` will first run `ERBTemplate` then `CoffeeScriptTemplate`.

All `Engine`s must follow the `Tilt::Template` interface. It is recommended to subclass `Tilt::Template`.

Its recommended that you register engine changes on your local `Environment` instance.

    environment.register_engine '.foo', FooProcessor

The global registry is exposed for plugins to register themselves.

    Sprockets.register_engine '.sass', SassTemplate

### Public Instance Methods

engine_extensions() click to toggle source

Returns an `Array` of engine extension `String`s.

    environment.engine_extensions
    # => ['.coffee', '.sass', ...]

    # File lib/sprockets/engines.rb, line 54
    def engine_extensions
      @engines.keys
    end

engines(ext = nil) click to toggle source

Returns an `Array` of `Engine`s registered on the `Environment`. If an `ext` argument is supplied, the `Engine` register under that extension will be returned.

    environment.engines
    # => [CoffeeScriptTemplate, SassTemplate, ...]

    environment.engines('.coffee')
    # => CoffeeScriptTemplate

    # File lib/sprockets/engines.rb, line 41
    def engines(ext = nil)
      if ext
        ext = Sprockets::Utils.normalize_extension(ext)
        @engines[ext]
      else
        @engines.dup
      end
    end

register_engine(ext, klass) click to toggle source

Registers a new Engine `klass` for `ext`. If the `ext` already has an engine registered, it will be overridden.

    environment.register_engine '.coffee', CoffeeScriptTemplate

    # File lib/sprockets/engines.rb, line 63
    def register_engine(ext, klass)
      ext = Sprockets::Utils.normalize_extension(ext)
      @engines[ext] = klass
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.