Method: Sprockets::Transformers#register_transformer

Defined in:
lib/sprockets/transformers.rb

#register_transformer(from, to, proc) ⇒ Object

Public: Register a transformer from and to a mime type.

from - String mime type to - String mime type proc - Callable block that accepts an input Hash.

Examples

register_transformer 'text/coffeescript', 'application/javascript',
  ConvertCoffeeScriptToJavaScript

register_transformer 'image/svg+xml', 'image/png', ConvertSvgToPng

Returns nothing.


38
39
40
41
42
43
# File 'lib/sprockets/transformers.rb', line 38

def register_transformer(from, to, proc)
  self.config = hash_reassoc(config, :registered_transformers) do |transformers|
    transformers << Transformer.new(from, to, proc)
  end
  compute_transformers!(self.config[:registered_transformers])
end