gruntjs/grunt-contrib-handlebars

Addition of task event emitting?

Closed this issue · 2 comments

I'm currently working with the following task definition for grunt-contrib-handlebars to compile my server-side handlebars templates down into templates accessible on the client:

var templateMap = [];

handlebars: {
  compile: {
    options: {
      amd: true,
      namespace: false,
      processName: function(filePath) {
        templateMap.push(filePath.replace('.hbs', ''));
        return filePath;
      }
    },
    files: [{
      expand: true,
      cwd: 'src/app/views/',
      src: ['**/*.hbs'],
      dest: 'public/scripts/templates/',
      ext: '.js'
    }]
  }
}

// do something with templateMap after task finishes

I've run into a problem where I need to grab each of the template names and stash them in an array for later use in my Gruntfile.

This seems like an odd way to do this and I'm wondering if it would benefit others, as well as myself, to emit some events at key places during task execution.

I think I'm going to fork for now and just implement it myself so it doesn't feel too hacky, but I figured I'd put it out there and see if the community had need of this type of addition.

Here's what I've added for my own use case, but I'm thinking there are more/different events that may be beneficial as well.

https://github.com/jasonmerino/grunt-contrib-handlebars/compare/v0.5.12build

Hey Jason! You're totally right that event emitting would be helpful. It's something we're working on for Grunt 0.5 but it's a long way off. I'm going to close this for now, but thanks for taking the time to post this issue!