Skip to content

188 handlebars helpers in ~20 categories. Can be used with Assemble, Ghost, YUI, express.js etc.

License

Notifications You must be signed in to change notification settings

helpers/handlebars-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

handlebars-helpers NPM version NPM monthly downloads NPM total downloads Linux Build Status Windows Build Status

More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate, Verb, Ghost, gulp-handlebars, grunt-handlebars, consolidate, or any node.js/Handlebars project.

You might also be interested in template-helpers.

Install

Install with npm:

$ npm install --save handlebars-helpers

Install with yarn:

$ yarn add handlebars-helpers

Browser usage

See how to use handlebars-helpers in the browser.

Usage

The main export returns a function that needs to be called to expose the object of helpers.

Get all helpers

var helpers = require('handlebars-helpers')();
//=> returns object with all (130+) helpers

Get a specific helper collection

Helper collections are exposed as getters, so only the helpers you want will be required and loaded.

var helpers = require('handlebars-helpers');
var math = helpers.math();
//=> only the `math` helpers

var helpers = require('handlebars-helpers');
var array = helpers.array();
//=> only the `collections` helpers

Get multiple helpers collections

Helper collections are exposed as getters, so only the helpers you want will be required and loaded.

var helpers = require('handlebars-helpers')(['math', 'string']);
//=> only the `math` and `string` helpers

Optionally pass your own handlebars

var handlebars = require('handlebars');
var helpers = require('handlebars-helpers')({
  handlebars: handlebars
});

// or for a specific collection
var math = helpers.math({
  handlebars: handlebars
});

Helpers

Categories

Currently 189 helpers in 20 categories:

All helpers

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)

Visit the: code | unit tests | issues)


array

Returns all of the items in an array after the specified index. Opposite of before.

Params

  • array {Array}: Collection
  • n {Number}: Starting index (number of items to exclude)
  • returns {Array}: Array exluding n items.

Example

<!-- array: ['a', 'b', 'c'] -->
{{after array 1}}
<!-- results in: '["c"]' -->

Cast the given value to an array.

Params

  • value {any}
  • returns {Array}

Example

{{arrayify "foo"}}
<!-- results in: [ "foo" ] -->

Return all of the items in the collection before the specified count. Opposite of after.

Params

  • array {Array}
  • n {Number}
  • returns {Array}: Array excluding items after the given number.

Example

<!-- array: ['a', 'b', 'c'] -->
{{before array 2}}
<!-- results in: '["a", "b"]' -->