Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

base-helpers

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-helpers

Adds support for managing template helpers to your base application.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
decreased by-16.3%
Maintainers
1
Weekly downloads
 
Created
Source

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

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

  • name {String}: Helper name
  • fn {Function}: Helper function.

Example

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

.helpers

Register multiple template helpers.

Params

  • helpers {Object|Array}: Object, array of objects, or glob patterns.

Example

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

.asyncHelper

Register an async helper.

Params

  • name {String}: Helper name.
  • fn {Function}: Helper function

Example

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

.asyncHelpers

Register multiple async template helpers.

Params

  • helpers {Object|Array}: Object, array of objects, or glob patterns.

Example

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

.getHelper

Get a previously registered helper.

Params

  • name {String}: Helper name
  • returns {Function}: Returns the registered helper function.

Example

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

.getAsyncHelper

Get a previously registered async helper.

Params

  • name {String}: Helper name
  • returns {Function}: Returns the registered helper function.

Example

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

.hasHelper

Return true if sync helper name is registered.

Params

  • name {String}: sync helper name
  • returns {Boolean}: Returns true if the sync helper is registered

Example

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

.hasAsyncHelper

Return true if async helper name is registered.

Params

  • name {String}: Async helper name
  • returns {Boolean}: Returns true if the async helper is registered

Example

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

.helperGroup

Register a namespaced helper group.

Params

  • helpers {Object|Array}: Object, array of objects, or glob patterns.

Example

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

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

History

v0.2.0

  • adds support for passing helper groups as a function. For example, the log helper can be a function, but it can also have log.warning and log.info functions as properties.

About

Contributing

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

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

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


This file was generated by verb-generate-readme, v0.4.1, on January 17, 2017.

Keywords

FAQs

Package last updated on 17 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc