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`
# 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.
# 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.
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.
See also: wycats/rake-pipeline-web-filters#43