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

Add a filter option to read operation #2

Open
jamesspencer opened this issue May 8, 2013 · 2 comments
Open

Add a filter option to read operation #2

jamesspencer opened this issue May 8, 2013 · 2 comments

Comments

@jamesspencer
Copy link

It would be very useful to filter the text retrieved during read operations by passing a function to be called each time text is extracted.

My use-case is such that I have to manipulate the urls retrieved when scanning the src attribute of some script tags before they are used in any subsequent tasks.

@cgross
Copy link
Owner

cgross commented May 8, 2013

Hmm. You could always use callback for that. Not sure it would be much simpler if done as part of read. You can write to a task config by doing something like:

grunt.config(['dom_munger','data','stuff'],[1,2,3]);

@jamesspencer
Copy link
Author

I'm currently using the callback option to perform this task but the code I've written is almost exactly the same as the read operation with the only difference being a modification of the attribute I've read. I reckon that the ability to mutate the data gathered by read would be useful in enough cases to warrant adding an option for it.

I've added a pull request to show the relatively minimal impact this should have.

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

2 participants