Class: Sprockets::SafetyColons

### Home Classes Methods

### In Files

- lib/sprockets/safety_colons.rb

### Parent

Tilt::Template

### Methods

- #evaluate
- #prepare

### 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::SafetyColons

For JS developers who are colonfobic, concatenating JS files using the module pattern usually leads to syntax errors.

The `SafetyColons` processor will insert missing semicolons to the end of the file.

This behavior can be disabled with:

    environment.unregister_postprocessor 'application/javascript', Sprockets::SafetyColons

### Public Instance Methods

evaluate(context, locals, &block) click to toggle source

    # File lib/sprockets/safety_colons.rb, line 18
    def evaluate(context, locals, &block)
      # If the file is blank or ends in a semicolon, leave it as is
      if data =~ /\A\s*\Z/ || data =~ /;\s*\Z/
        data
      else
        # Otherwise, append a semicolon and newline
        "#{data};\n"
      end
    end

prepare() click to toggle source

    # File lib/sprockets/safety_colons.rb, line 15
    def prepare
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.