## Usage In addition to what's shown in the below examples, if a glob pattern or valid filepath is passed, a `stat` object will be added to the `file` object as well. ```js const Loader = require('{%= name %}'); const loader = new Loader([options]); const files = loader.load('*.hbs'); console.log(files); //<= object of vinyl files ``` ## Supported formats ```js // filepath loader.load('a/b/c/some-template.hbs'); // array of filepaths loader.load([ 'a/b/c/some-template.hbs', 'a/b/c/other-template.hbs' ]); // glob pattern loader.load('*.hbs'); // array of globs loader.load(['*.hbs', '*.tmpl']); // object loader.load({path: 'foo'}); // key-value loader.load('d', {path: 'd'}); loader.load('e', {path: 'e'}); loader.load('f', {path: 'f'}); // object of objects loader.load({ a: {path: 'a'}, b: {path: 'b'}, c: {path: 'c'} }); // array of objects loader.load([ {path: 'a'}, {path: 'b'}, {path: 'c'} ]); // array of nested objects loader.load([ { a: {path: 'test/fixtures/a.md'}, b: {path: 'test/fixtures/b.md'}, c: {path: 'test/fixtures/c.md'}, }, { d: {path: 'test/fixtures/d.md'}, e: {path: 'test/fixtures/e.md'}, f: {path: 'test/fixtures/f.md'}, } ]); ``` ## Options ### options.cwd Type: `String` Default: `process.cwd()` Pass the current working directory to use for resolving paths. ### options.renameKey Type: `Function` Default: `file.path` The path that was given or globbed when the file was created. Function to modify `file.key`, which is the property used for setting files on `loader.cache`. **Example** ```js const loader = new Loader({ renameKey: file => file.basename }); ``` This is functionally equivalent to: ```js loader.cache[file.basename] = file; ``` ### options.onLoad Type: `Function` Default: `undefined` Function to run on each file before it's added to the cache. ```js const loader = new Loader({ onLoad: file => { // optionally return a new file, or just modify properties } }); ``` ## API {%= apidocs("index.js") %} ## Release history **v2.0.0** - The `loaderFn` option has been deprecated and renamed to `onLoad`, use `options.onLoad` going forward.