Module: Sprockets::Compressing
- Defined in:
- lib/emcee/helpers/sprockets_compressing.rb
Instance Method Summary collapse
- #html_compressor ⇒ Object
-
#html_compressor=(compressor) ⇒ Object
Assign a compressor to run on ‘text/html’ assets.
Instance Method Details
#html_compressor ⇒ Object
3 4 5 |
# File 'lib/emcee/helpers/sprockets_compressing.rb', line 3 def html_compressor @html_compressor if defined? @html_compressor end |
#html_compressor=(compressor) ⇒ Object
Assign a compressor to run on ‘text/html’ assets.
The compressor object must respond to ‘compress’.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/emcee/helpers/sprockets_compressing.rb', line 10 def html_compressor=(compressor) unregister_bundle_processor 'text/html', html_compressor if html_compressor @html_compressor = nil return unless compressor if compressor.is_a?(Symbol) compressor = compressors['text/html'][compressor] || raise(Error, "unknown compressor: #{compressor}") end if compressor.respond_to?(:compress) klass = Class.new(Processor) do @name = "html_compressor" @processor = proc { |context, data| compressor.compress(data) } end @html_compressor = :html_compressor else @html_compressor = klass = compressor end register_bundle_processor "text/html", klass end |