timdp / metalsmith-discover-helpers

Discovers your template helpers and registers them with Handlebars.
MIT License
9 stars 5 forks source link

Accept multiple directories? #1

Open zslabs opened 8 years ago

zslabs commented 8 years ago

Hi, Thanks so much for this package! Can it accept multiple directories? The reason I'm asking is because I'd love to bundle both https://github.com/assemble/handlebars-helpers and my own. Thanks!

timdp commented 8 years ago

Thanks for the suggestion! I'll add it asap.

For the time being, I think you should just be able to call the plugin multiple times using the JS API. If you're using config files, that won't help though.

zslabs commented 8 years ago

I know this is a separate concern, but do you know how to loop through and add-in all of the helpers from that repo automatically? I'd rather not specifically create each one over and just have them available to me.

timdp commented 8 years ago

SInce they're in a single directory, you can probably just pass that directory to this plugin, no? If not, you can use a module such as globule to locate the source files and then pass those to this plugin.

That's also basically what I had in mind for this plugin. I'd add an option called files that accepts an array of wildcard patterns. An example config would look like:

{
  files: ['src/helpers/**/*.js', 'node_modules/handlebars-helpers/lib/helpers/*.js']
}

The directory option would still apply: every file pattern would be relative to that directory, if provided.

zslabs commented 8 years ago

Cool thanks!

timdp commented 8 years ago

I'm gonna keep this issue open so I can track the new feature I described. :-)

mpalpha commented 5 years ago

you can add "handlebars-helpers" to the current handlebars instance...

import handlebars from 'handlebars';
import handlebarsHelpers from 'handlebars-helpers';

// Register handlebars-helpers library
handlebarsHelpers({ handlebars });

now I can use them in metalsmith.