Class: Emcee::Compressors::HtmlCompressor
- Inherits:
-
Object
- Object
- Emcee::Compressors::HtmlCompressor
- Defined in:
- lib/emcee/compressors/html_compressor.rb
Overview
HtmlCompressor is a very basic compressor that removes blank lines and comments from an HTML file.
Constant Summary collapse
- HTML_COMMENTS =
/\<!\s*--(?:.*?)(?:--\s*\>)/m- JS_MULTI_COMMENTS =
/\/\*(?:.*?)\*\//m- JS_COMMENTS =
/^\s*\/\/.*$/- BLANK_LINES =
/^[\s]*$\n/
Instance Method Summary collapse
Instance Method Details
#compress(string) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/emcee/compressors/html_compressor.rb', line 11 def compress(string) ops = [HTML_COMMENTS, JS_MULTI_COMMENTS, JS_COMMENTS, BLANK_LINES] ops.reduce(string) do |output, op| output.gsub(op, "") end end |