Sha256: bc80ee9d305142025fcdcde2a6b79d6c7c1358082a51095ad8ab48a3f7e9505d
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
module Middleman module MinifyHtml class << self def registered(app) app.set :html_compressor, false app.after_configuration do unless respond_to?(:html_compressor) && html_compressor require 'html_compressor' set :html_compressor, ::HtmlCompressor::HtmlCompressor.new end # Setup Rack to watch for inline JS use MinifyHtmlRack, :compressor => html_compressor end end alias :included :registered end class MinifyHtmlRack # Init # @param [Class] app # @param [Hash] options def initialize(app, options={}) @app = app @compressor = options[:compressor] end # Rack interface # @param [Rack::Environmemt] env # @return [Array] def call(env) status, headers, response = @app.call(env) path = env["PATH_INFO"] if path.end_with?('.html') uncompressed_source = ::Middleman::Util.extract_response_text(response) minified_html = @compressor.compress(uncompressed_source) headers["Content-Length"] = ::Rack::Utils.bytesize(minified_html).to_s response = [minified_html] end [status, headers, response] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
middleman-minify-html-3.0.0.beta.3 | lib/middleman-minify-html/extension.rb |