module Sprockets::Processing
def add_engine_to_trail(ext, klass)
def add_engine_to_trail(ext, klass) @trail.append_extension(ext.to_s) if klass.respond_to?(:default_mime_type) && klass.default_mime_type if format_ext = extension_for_mime_type(klass.default_mime_type) @trail.alias_extension(ext.to_s, format_ext) end end end
def bundle_processors(mime_type = nil)
All `Processor`s must follow the `Tilt::Template` interface. It is
individual files.
Bundle Processors are ran on concatenated assets rather than
extension will be returned.
argument is supplied, the processors registered under that
Returns an `Array` of `Processor` classes. If a `mime_type`
def bundle_processors(mime_type = nil) if mime_type @bundle_processors[mime_type].dup else deep_copy_hash(@bundle_processors) end end
def format_extensions
# => ['.js', '.css']
format_extensions
Returns an `Array` of format extension `String`s.
def format_extensions @trail.extensions - @engines.keys end
def postprocessors(mime_type = nil)
All `Processor`s must follow the `Tilt::Template` interface. It is
Postprocessors are ran after Preprocessors and Engine processors.
extension will be returned.
argument is supplied, the processors registered under that
Returns an `Array` of `Processor` classes. If a `mime_type`
def postprocessors(mime_type = nil) if mime_type @postprocessors[mime_type].dup else deep_copy_hash(@postprocessors) end end
def preprocessors(mime_type = nil)
All `Processor`s must follow the `Tilt::Template` interface. It is
processors.
Preprocessors are ran before Postprocessors and Engine
extension will be returned.
argument is supplied, the processors registered under that
Returns an `Array` of `Processor` classes. If a `mime_type`
def preprocessors(mime_type = nil) if mime_type @preprocessors[mime_type].dup else deep_copy_hash(@preprocessors) end end
def processors(*args)
def processors(*args) preprocessors(*args) end
def register_bundle_processor(mime_type, klass, &block)
end
data.gsub(...)
register_bundle_processor 'text/css', :my_processor do |context, data|
A block can be passed for to create a shorthand processor.
register_bundle_processor 'text/css', Sprockets::CharsetNormalizer
Registers a new Bundle Processor `klass` for `mime_type`.
def register_bundle_processor(mime_type, klass, &block) if block_given? name = klass.to_s klass = Class.new(Processor) do @name = name @processor = block end end @bundle_processors[mime_type].push(klass) end
def register_postprocessor(mime_type, klass, &block)
end
data.gsub(...)
register_postprocessor 'text/css', :my_processor do |context, data|
A block can be passed for to create a shorthand processor.
register_postprocessor 'text/css', Sprockets::CharsetNormalizer
Registers a new Postprocessor `klass` for `mime_type`.
def register_postprocessor(mime_type, klass, &block) if block_given? name = klass.to_s klass = Class.new(Processor) do @name = name @processor = block end end @postprocessors[mime_type].push(klass) end
def register_preprocessor(mime_type, klass, &block)
end
data.gsub(...)
register_preprocessor 'text/css', :my_processor do |context, data|
A block can be passed for to create a shorthand processor.
register_preprocessor 'text/css', Sprockets::DirectiveProcessor
Registers a new Preprocessor `klass` for `mime_type`.
def register_preprocessor(mime_type, klass, &block) if block_given? name = klass.to_s klass = Class.new(Processor) do @name = name @processor = block end end @preprocessors[mime_type].push(klass) end
def register_processor(*args, &block)
def register_processor(*args, &block) register_preprocessor(*args, &block) end
def unregister_bundle_processor(mime_type, klass)
unregister_bundle_processor 'text/css', Sprockets::CharsetNormalizer
Remove Bundle Processor `klass` for `mime_type`.
def unregister_bundle_processor(mime_type, klass) if klass.is_a?(String) || klass.is_a?(Symbol) klass = @bundle_processors[mime_type].detect { |cls| cls.respond_to?(:name) && cls.name == "Sprockets::Processor (#{klass})" } end @bundle_processors[mime_type].delete(klass) end
def unregister_postprocessor(mime_type, klass)
unregister_postprocessor 'text/css', Sprockets::DirectiveProcessor
Remove Postprocessor `klass` for `mime_type`.
def unregister_postprocessor(mime_type, klass) if klass.is_a?(String) || klass.is_a?(Symbol) klass = @postprocessors[mime_type].detect { |cls| cls.respond_to?(:name) && cls.name == "Sprockets::Processor (#{klass})" } end @postprocessors[mime_type].delete(klass) end
def unregister_preprocessor(mime_type, klass)
unregister_preprocessor 'text/css', Sprockets::DirectiveProcessor
Remove Preprocessor `klass` for `mime_type`.
def unregister_preprocessor(mime_type, klass) if klass.is_a?(String) || klass.is_a?(Symbol) klass = @preprocessors[mime_type].detect { |cls| cls.respond_to?(:name) && cls.name == "Sprockets::Processor (#{klass})" } end @preprocessors[mime_type].delete(klass) end
def unregister_processor(*args)
def unregister_processor(*args) unregister_preprocessor(*args) end