Sha256: 1a43448e3d7e9a11d08350aa0df5173291099abf419982402412de648efcf1df
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
module HtmlCompressor class Rack DEFAULT_OPTIONS = { :enabled => true, :remove_multi_spaces => true, :remove_comments => true, :remove_intertag_spaces => false, :remove_quotes => true, :compress_css => false, :compress_javascript => false, :simple_doctype => false, :remove_script_attributes => true, :remove_style_attributes => true, :remove_link_attributes => true, :remove_form_attributes => false, :remove_input_attributes => true, :remove_javascript_protocol => true, :remove_http_protocol => true, :remove_https_protocol => false, :preserve_line_breaks => false, :simple_boolean_attributes => true } def initialize app, options = {} @app = app options = DEFAULT_OPTIONS.merge(options) @compressor = HtmlCompressor::Compressor.new(options) end def call env status, headers, body = @app.call(env) if (File.extname(env["PATH_INFO"]) != '.php') && headers.key?('Content-Type') && (headers['Content-Type'] =~ /html/) content = '' body.each do |part| content << part end content = @compressor.compress(content) headers['Content-Length'] = content.length.to_s if headers['Content-Length'] [status, headers, [content]] else [status, headers, body] end ensure body.close if body.respond_to?(:close) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
middleman-minify-html-3.1.0 | lib/middleman-minify-html/vendor/htmlcompressor-0.0.6/lib/htmlcompressor/rack.rb |