helper-loader

0.1.5 • Public • Published

helper-loader NPM version

Load template engine helpers (handlebars, lo-dash, etc) from file paths, globs, arrays or objects.

Install

Install with npm:

npm i helper-loader --save-dev

Usage

var Loader = require('helper-loader');
var helpers = new Loader();

API

loader

Create a new instance of Loader, optionally passing default options.

  • options {Object}: Default options for front-matter and helper naming.

Example:

var Loader = require('helper-loader');
var helpers = new Loader();

.option

Set or get an option.

  • key {String}: The name of the option.
  • value {*}: The value to assign.
  • returns: {*}
loader.option('a', true)
loader.option('a')
// => true

.load

Resolve and load helpers onto the cache.

  • returns {Object} loader
// require a helper
loader.load(require('foo'));
 
// Pass a string or array of file paths or glob patterns
loader.load('a.js');
loader.load(['a.js', 'b.js', 'c.js']);
loader.load(['*.js']);
 
// pass an object
loader.load({
    a: function (str) {
   return str;
  }
});
 
// pass an array of objects
helper.load([{
  a: function (str) {
   return str;
  },
  b: function (str) {
   return str;
  }
}]);

.set

Store a helper on the cache by name.

  • name {String}: Helper name
  • helper {String}: File path, glob pattern or object.
loader.set('foo', function(str) {
  return str;
})

.get

Get helper from the cache.

  • helper {String}: The name of the helper to get.
loader.get('foo')
//=> [function]

Author

Jon Schlinkert

License

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


This file was generated by verb-cli on August 13, 2014.

Package Sidebar

Install

npm i helper-loader

Weekly Downloads

2

Version

0.1.5

License

none

Last publish

Collaborators

  • doowb
  • jonschlinkert