Home

Awesome

base-helpers NPM version NPM monthly downloads NPM total downloads Linux Build Status

Adds support for managing template helpers to your base application.

Install

Install with npm:

$ npm install --save base-helpers

Install with yarn:

$ yarn add base-helpers

Usage

Register the plugin with your base application:

var Base = require('base');
var helpers = require('base-helpers');
base.use(helpers());

API

.helper

Register a template helper.

Params

Example

app.helper('upper', function(str) {
  return str.toUpperCase();
});

.helpers

Register multiple template helpers.

Params

Example

app.helpers({
  foo: function() {},
  bar: function() {},
  baz: function() {}
});

.asyncHelper

Register an async helper.

Params

Example

app.asyncHelper('upper', function(str, next) {
  next(null, str.toUpperCase());
});

.asyncHelpers

Register multiple async template helpers.

Params

Example

app.asyncHelpers({
  foo: function() {},
  bar: function() {},
  baz: function() {}
});

.getHelper

Get a previously registered helper.

Params

Example

var fn = app.getHelper('foo');

.getAsyncHelper

Get a previously registered async helper.

Params

Example

var fn = app.getAsyncHelper('foo');

.hasHelper

Return true if sync helper name is registered.

Params

Example

if (app.hasHelper('foo')) {
  // do stuff
}

.hasAsyncHelper

Return true if async helper name is registered.

Params

Example

if (app.hasAsyncHelper('foo')) {
  // do stuff
}

.helperGroup

Register a namespaced helper group.

Params

Example

// markdown-utils
app.helperGroup('mdu', {
  foo: function() {},
  bar: function() {},
});

// Usage:
// <%= mdu.foo() %>
// <%= mdu.bar() %>

History

v1.0.0

v0.2.0

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.5.0, on April 20, 2017.