alanshaw / grunt-include-replace

Grunt task to include files and replace variables. Allows for parameterised includes.
MIT License
200 stars 45 forks source link

Top-level `processIncludeContents` option #32

Open knuton opened 10 years ago

knuton commented 10 years ago

Because I need to apply a uniform transformation across both includes and "includers", I locally altered include-replace to optionally apply the processIncludeContents function not only to includes, but also to top-level files.

If this is welcome, I'd like to provide a patch for this.

includereplace: {
  dist: {
    options: {
      processIncludeContents: function (src, locals) {
        // do sthg!
      },
      // if this is thruthy, all levels will be processed with `processIncludeContents`
      processTopLevel: true
    },
    src: '*.html',
    dest: 'dist/'
  }
}
alanshaw commented 10 years ago

I can see how this would be useful. I'd like to not confuse the meaning of processIncludeContents though and have a processIncluderContents function as the new option.

Would definitely welcome a PR :)