Skip to content

Instantly share code, notes, and snippets.

@pk
Created November 9, 2011 15:25

Revisions

  1. pk created this gist Nov 9, 2011.
    17 changes: 17 additions & 0 deletions juicer_filter.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    module PK
    module Filter

    class Juice < Nanoc3::Filter
    identifier :juice
    type :text

    def run(content, params={})
    input_filename = File.join('content', @item.path)
    output_filename = File.absolute_path(File.join('tmp', "#{@item.path}"))
    system('juicer', 'merge', '--force', '-o', output_filename, input_filename)
    minified = File.open(output_filename, 'r') { |f| f.read }
    end
    end

    end
    end