diff --git a/README.md b/README.md
index 431a3b0..e44e4d5 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ grunt.initConfig({
your_target: {
options: {
//You typically would only specify one option per target but they may be combined
- read: {selector:'link',attribute:'href',writeto:'myCssRefs',isPath:true},
+ read: {selector:'link',attribute:'href',writeto:'myCssRefs',isPath:true, filter:function(val){return val;}},
remove: '#removeMe',
update: {selector:'html',attribute:'appmode',value:'production'},
append: {selector:'body',html:'
Im being appended
'},
@@ -55,7 +55,7 @@ grunt.initConfig({
Note: each option (except callback) requires a `selector`. This can be any valid JQuery selector.
#### options.read
-Extract the value of a given attribute from the set of matched elements then set the values into `dom_munger.data.{writeto}`. A typical use-case is to grab the script references from your html file and pass that to `concat`,`uglify`, or `cssmin`.
+Extract the value of a given attribute from the set of matched elements then set the values into `dom_munger.data.{writeto}`. If you pass a `filter` function it will be called against each attribute retrieved. A typical use-case is to grab the script references from your html file and pass that to `concat`,`uglify`, or `cssmin`.
```js
grunt.initConfig({
diff --git a/tasks/dom_munger.js b/tasks/dom_munger.js
index c48313e..8af1b0e 100644
--- a/tasks/dom_munger.js
+++ b/tasks/dom_munger.js
@@ -58,8 +58,11 @@ module.exports = function(grunt) {
if (!options.read.selector || !options.read.attribute || !options.read.writeto){
grunt.log.error('Read config missing selector, attribute, and/or writeto options');
} else {
+ if(!options.read.filter) {
+ options.read.filter = function(val) {return val;};
+ }
var vals = $.map($(options.read.selector),function(elem){
- return $(elem).attr(options.read.attribute);
+ return options.read.filter($(elem).attr(options.read.attribute));
});
if (options.read.isPath){