Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a Pass-Through filter #86

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

Implement a Pass-Through filter #86

ahawkins opened this issue Sep 2, 2012 · 1 comment

Comments

@ahawkins
Copy link

ahawkins commented Sep 2, 2012

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
Copy link
Author

ahawkins commented Sep 2, 2012

See also: wycats/rake-pipeline-web-filters#43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant