Miss any of our Open RFC calls?Watch the recordings here! »

helper-glob

0.1.0 • Public • Published

helper-glob NPM version

Template helper for globbing files. Works with handlebars, Lo-Dash or any template engine that supports helper functions.

Install with npm

npm i helper-glob --save

Usage

Lo-Dash

var _ = require('lodash');
 
_.template('<%= glob("files/*.txt") %>', {
  glob: require('helper-glob')
});
 
// glob and read files
var fs = require('fs');
_.template('<%= _.map(glob("files/*.txt"), read) %>', {
  glob: require('helper-glob'),
  read: function(fp) {
    return fs.readFileSync(fp, 'utf8');
  }
});
 

Handlebars

var handlebars = require('handlebars');
var fs = require('fs');
 
handlebars.registerHelper('glob', require('helper-glob'));
handlebars.registerHelper('read', function(fp) {
  return fs.readFileSync(fp, 'utf8');
});
{{glob 'files/*.txt'}}
 
<!-- glob and read files using subexpressions -->
{{#each (glob "files/*.hbs")}}
  {{read .}}
{{/each}}

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert
Released under the MIT license


This file was generated by verb on December 06, 2014. To update, run npm i -g verb && verb.

Install

npm i helper-glob

DownloadsWeekly Downloads

163

Version

0.1.0

License

MIT

Last publish

Collaborators

  • avatar