altano/handlebars-loader — pull request #10 by diurnalist (2014-08-07 13:35:49+00:00)
Title: Add support for converting helper/partial params to inline requires

In some cases it is desired to pass a module to a Handlebars partial or helper.
Normally, this can be accomplished with template data:

```javascript
var data = {
module: require('path/to/module')
};

template.render(data);
```

```html
{{helperThatWantsModule module}}
```

However, it is often simpler to just say what you need inside the template file itself:

```html
{{helperThatWantsModule "path/to/module"}}
```

In my specific use-case, which inspired this PR, I have a special helper that is responsible
for setting up and rendering subviews to a parent view:

```html
{{$view "path/to/subview" subviewArg="..."}}
```

Having the handlebars webpack loader identify these modules as dependencies and require them
inline is preferable, and not very difficult. By adding a `nestedRequires` option, which allows
the user to specify a conditional regex that defines what strings should be treated as modules.
As strings are processed by the Handlebars compiler, it can then replace them on the fly.