Class: BridgetownMinifyHtml::Minifier

Inherits:
Object
  • Object
show all
Defined in:
lib/bridgetown-minify-html/minifier.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  enabled: true,
  remove_spaces_inside_tags: true,
  remove_multi_spaces: true,
  remove_comments: true,
  remove_intertag_spaces: false,
  remove_quotes: false,
  simple_doctype: false,
  remove_script_attributes: false,
  remove_style_attributes: false,
  remove_link_attributes: false,
  remove_form_attributes: false,
  remove_input_attributes: false,
  remove_javascript_protocol: false,
  remove_http_protocol: false,
  remove_https_protocol: false,
  preserve_line_breaks: false,
  simple_boolean_attributes: false,
  compress_js_templates: false,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ Minifier

Returns a new instance of Minifier.



28
29
30
31
# File 'lib/bridgetown-minify-html/minifier.rb', line 28

def initialize(site)
  @site = site
  @minified_count = 0
end

Instance Method Details

#call!Object



33
34
35
36
37
38
39
# File 'lib/bridgetown-minify-html/minifier.rb', line 33

def call!
  (@site.pages + @site.documents).each do |page|
    minify_page(page)
  end

  Bridgetown.logger.info "Minify HTML:", "Complete, Processed #{@minified_count} file(s)"
end