Implement a Pass-Through filter #86

Open
ahawkins opened this Issue Sep 2, 2012 · 1 comment

1 participant

@ahawkins

A pass through filter is like a
matcher but allows you to match like a matcher and select files
outside the glob as well. Also the outputs from the filters do not
directly correspond to the inputs. Here's an example:

# This line has to allow all files because eventually
# `index.html` is needed down the line by a filter. 
# `index.html` must be an input so its content can be
# read and its content be replaced.
allow "*.handlebars" do
  # works like a normal filter but by default only uses
  # the pipeline's matched files. Matched files match the
  # the glob specified in `allow`
  handlebars_script_tag

  # This filter takes the outputs of the previous filter
  # HTML script tags and injects them into `index.html`. 
  # This filter must read index.html as an input and 
  # write to it as an output. The trick here is to 
  # keep the matched files the inputs so they can 
  # be manipulated by other filters.
  inject_script_tag "index.html"

  # Other filters can request files outside the main
  # glob as inputs at this point and continue there work.
  # It's important to note that inputs to filters at this
  # point are not "index.html". They are all the files 
  # in the pipeline.
end

Implementing a pass through filter also makes generating a cache manifest easy. Simply match everything and generate an output. The original inputs are still there. This also encompasses the idea that sometimes you don't want to destroy input files, just use them.

I have implemented something like this for use in Iridium. I'm wondering if it can be adapter and pushed upstream.

@ahawkins ahawkins referenced this issue in wycats/rake-pipeline-web-filters Nov 15, 2012
Open

HTML5 cache manifest filter #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment