Package Exports
- helper-cache
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (helper-cache) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
helper-cache

Easily register and get helper functions to be passed to any template engine or node.js application. Methods for both sync and async helpers.
Install with npm
npm i helper-cache --save
Usage
HelperCache
Create an instance of HelperCache
, optionally passing default options
.
options
{Object}: Default options to use.bind
{Boolean}: Bind functions tothis
. Defaults tofalse
.thisArg
{Boolean}: The context to use.
var HelperCache = require('helper-cache');
var helpers = new HelperCache();
.addHelper
Register a helper.
name
{String}: The name of the helper.fn
{Function}: Helper function.returns
{Object}: Returnthis
to enable chaining
helpers.addHelper('lower', function(str) {
return str.toLowerCase();
});
.addAsyncHelper
Register an async helper.
key
{String}: The name of the helper.fn
{Function}: Helper function.returns
{Object}: Returnthis
to enable chaining
helpers.addAsyncHelper('foo', function (str, callback) {
callback(null, str + ' foo');
});
.addHelpers
Load an object of helpers.
key
{String}: The name of the helper.fn
{Function}: Helper function.returns
{Object}: Returnthis
to enable chaining.
helpers.addHelpers({
a: function() {},
b: function() {},
c: function() {},
});
.addAsyncHelpers
Load an object of async helpers.
key
{String}: The name of the helper.fn
{Function}: Helper function.returns
{Object}: Returnthis
to enable chaining
helpers.addAsyncHelpers({
a: function() {},
b: function() {},
c: function() {},
});
.getHelper
Get a registered helper.
key
{String}: The helper to get.returns
{Object}: The specified helper. If nokey
is passed, the entire cache is returned.
helpers.getHelper('foo');
Related projects
- engine-cache: express.js inspired template-engine manager.
- handlebars-helpers: 120+ Handlebars helpers in ~20 categories, for Assemble, YUI, Ghost… more
- template-helpers: Generic JavaScript helpers that can be used with any template… more
- template: Render templates from any engine. Make custom template types, use… more
Running tests
Install dev dependencies:
npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jon Schlinkert
License
Copyright (c) 2014-2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb-cli on April 23, 2015.