moudy/broccoli-handlebars — pull request #3 by greghuc (2014-11-27 18:59:41+00:00)
Title: Add destfile option to enable plugin to be used with non-html files 

Handlebars (and mustache) can be used to templatise any type of file, not just .html files. However, the current broccoli-handlebars implicitly assumes it's used to process html pages only: an input file called `example.hbs` is output to `example.html` in the output Broccoli tree. This assumption makes it problematic to use this project to process non-html files, like json or html.

This pull request fixes this by adding a `destFile` option, which takes a function. This function is called for each input file (with its `filename`) to get the name of the compiled file in the Broccoli output tree. I've used it to convert `example.json.hbs` to `example.json` (stripping the .hbs suffix). This is equivalent to behaviour in the Ruby on Rails Sprockets assets pipeline. Config used:
```js
var tree = broccoliHandlebars(tree, {
destFile: function (filename) { return filename.replace(/\.(hbs|handlebars)$/, ''); }
});
```

If the `destFile` option is not set, existing behaviour is used: `example.hbs` becomes `example.html`

I tested this by running the plugin with no `destFile` option, and output filenames were the same as before. I then set the `destFile` option as above, and output filenames were expected (.hbs and .handlebars suffixes were stripped.

Cheers

Greg