helper-cache
Easily get and set template helper functions to pass to any application or template engine.
Install
Install with npm:
npm i helper-cache --save-dev
Run tests
npm test
See the tests for examples.
Usage
Create an instance of Helpers
var Helpers = require('helper-cache');
var helpers = new Helpers();
API
.addHelper (sync)
Register sync helpers:
helpers.addHelper('lower', function lower(str) {
return str.toLowerCase();
});
helpers.addHelper('upper', function upper(str) {
return str.toUpperCase();
});
console.log(helpers)
.addHelpers (sync)
Or, use the plural version and pass an object of helpers:
helpers.addHelpers({
lower: function(str) {
return str.toLowerCase();
},
upper: function(str) {
return str.toUpperCase();
}
});
.getHelper (sync)
Get sync helpers:
var helper = helpers.getHelper('a');
.addHelperAsync
Register async helpers:
helpers.addHelperAsync('lower', function lower(str, next) {
next(null, str.toLowerCase());
});
helpers.addHelperAsync('upper', function upper(str, next) {
next(null, str.toUpperCase());
});
console.log(helpers)
.addHelpersAsync
Or, use the plural version and pass an object of helpers:
helpers.addHelpersAsync({
lower: function(str) {
return str.toLowerCase();
},
upper: function(str) {
return str.toUpperCase();
}
});
.getHelperAsync
Get async helpers:
var helper = helpers.getHelperAsync('lower');
Related
Check out these related libs:
Author
Jon Schlinkert
Brian Woodward
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on November 04, 2014.