Swappable CSS minification engines. Each accepts and returns a string.
Public class methods
cssmin
(input_string)
CSS minification engine that mostly uses the CSSMin gem, a Ruby port of Lecomte’s YUI Compressor and Schlueter’s PHP cssmin.
Sources:
[show source]
# File lib/asset_hat/css.rb, line 116 116: def self.cssmin(input_string) 117: output = CSSMin.minify(input_string) 118: 119: # Remove rules that have empty declaration blocks 120: output.gsub!(/\}([^\}]+\{;\}){1,}/, '}') 121: 122: output 123: end
weak
(input_string)
Barebones CSS minification engine that only strips whitespace from the start and end of every line, including linebreaks. For safety, doesn’t attempt to parse the CSS itself.
[show source]
# File lib/asset_hat/css.rb, line 94 94: def self.weak(input_string) 95: input = StringIO.new(input_string) 96: output = StringIO.new 97: 98: input.each do |line| 99: # Remove indentation and trailing whitespace (including line breaks) 100: line.strip! 101: next if line.blank? 102: 103: output.write line 104: end 105: 106: output.rewind 107: output.read 108: end