Class: Csso::Compressor
- Inherits:
-
Object
- Object
- Csso::Compressor
- Defined in:
- lib/csso/compressor.rb
Overview
sprockets-compatible compressor
Defined Under Namespace
Classes: Legacy
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(_path, &block) ⇒ Compressor
constructor
sprockets 2:.
- #render(_context, _opts = {}) ⇒ Object
Constructor Details
#initialize(_path, &block) ⇒ Compressor
sprockets 2:
28 29 30 |
# File 'lib/csso/compressor.rb', line 28 def initialize(_path, &block) @block = block end |
Class Method Details
.call(input) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/csso/compressor.rb', line 6 def self.call(input) require 'csso' # TODO: settings? if input[:metadata] && input[:metadata][:map] css, map_json = Csso.optimize_with_sourcemap( input[:data], # Sprockets::PathUtils.split_subpath(input[:load_path], input[:filename]) # sprockets seems to ignore filenames here, so we may save some mem: 'uri' ) { data: css, map: Sprockets::SourceMapUtils.combine_source_maps(input[:metadata][:map], JSON.parse(map_json)) } else { data: Csso.optimize(input[:data], true) } end end |
Instance Method Details
#render(_context, _opts = {}) ⇒ Object
32 33 34 |
# File 'lib/csso/compressor.rb', line 32 def render(_context, _opts = {}) self.class.call(data: @block.call)[:data] end |