Sha256: 875616b0d7d236fdd6a01c243ae49ab01c805b80081185e382f6969b136d0527

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'html_press'

module Jekyll
  module MinifyHTML
    def output_file(dest, content)
      FileUtils.mkdir_p(File.dirname(dest))
      File.open(dest, 'w') do |f|
        f.write(content)
      end
    end

    def output_html(path, content)
      if @site.config['env'] && @site.config['env'].downcase === 'production'
        content = HtmlPress.press(content)
      end
      output_file(path, content)
    end

  end

  class Post
    include MinifyHTML

    def write(dest)
      dest_path = destination(dest)
      output_html(dest_path, output)
    end
  end

  class Page
    include MinifyHTML

    def write(dest)
      dest_path = destination(dest)
      if File.extname(dest_path).downcase == '.html'
        output_html(dest_path, output)
      else
        output_file(dest_path, output)
      end
    end
  end
  class ConvertiblePage
    include MinifyHTML

    def write(dest)
      dest_path = destination(dest)
      if File.extname(dest_path).downcase == '.html'
        output_html(dest_path, output)
      else
        output_file(dest_path, output)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-minify-html-1.0.1 lib/jekyll-minify-html.rb
jekyll-minify-html-1.0.0 lib/jekyll-minify-html.rb