gruntjs/grunt-contrib-handlebars — pull request #66 by nicolai86 (2013-08-28 11:01:27+00:00)
Title: Add support for glob/ pattern matching

Hey there!

I'm working on Backbone project with RequireJS and we'd like to require our templates individually. That's possible using

``` javascript
options: {
namespace: false,
amd: true
}
```

but it forces us to update the Gruntfile every time we create a new template. Thus we've patched `grunt-contrib-handlebars` to support the following task definition using globs:

``` javascript
handlebars: {
compile: {
options: {
namespace: false,
amd: true
},
files: [
{
pattern: '<%= yeoman.app %>/scripts/templates/**/*.hbs',
base: '<%= yeoman.app %>/scripts/templates/',
dest: '.tmp/scripts/templates/'
}
]
}
},
```

Pattern defines a glob which is used to list all templates to be processed.
The base is used to normalize the path each template is stored. This is important because the glob will return paths like `app/scripts/templates/hello/world.hbs` but we want it to be available via require as `templates/hello/world`.
Lastly, dest is used to specify where we want the files to be placed at.

This PR is mainly for discussion because I've refactored the task quite a bit to get a feeling for the structure ( The methods are quite long with multiple concerns so it's somewhat hard to follow ).

What do you think about the above pattern matching? I guess it's mainly interesting for people working with RequireJS, because everybody else would want their namespace.

There are certain use cases I've not yet started to worry about (e.g. partials and helpers). Just a rough draft.

Thanks for this grunt task :)