Socket
Socket
Sign inDemoInstall

gb-handlebars-helpers

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gb-handlebars-helpers

handy handlebars helpers


Version published
Maintainers
1
Install size
844 kB
Created

Readme

Source

Goodybag Handlebars Helpers

Lightweight collection of useful handlebars helpers for the browser or server.

Build Status

Install

bower install gb-handlebars-helpers
npm install gb-handlebars-helpers

Usage

Register the helpers:

var Handlebars = require('handlebars');
var helpers = require('gb-handlebars-helpers');

// register all the helpers
helpers.register(Handlebars);

// or cherry pick what you need
helpers.register(Handlebars, ['truncate', 'dollars']);

Using helpers:

// use a helper directly
console.log(Handlebars.helpers.dollars(234)); // '2.34'

// or in a template
var templateStr = 'You balance: ${{dollars amount}}';
var template = Handlebars.compile(templateStr);
var output = template({ amount: 234 }); // 'Your balance: $2.34'

API

helpers.register(Handlebars)

Register all helpers

helpers.register(Handlebars, [ a, b, ... ])

Register with a list of helper names

helpers.register(Handlebars, a, b, ...)

Register helpers by passing in parameters

helpers.unregister(Handlebar)

helpers.unregister(Handlebars, [ a, b, ... ])

helpers.unregister(Handlebars, a, b, ... )

Unregister using same signatures as .register

Helpers

Comparison

  • eq
  • dneq
  • lt
  • lte
  • gt
  • gte

Math

  • add
  • subtract
  • multiply
  • divide
  • intDivide
  • mod

String manipulation

  • truncate
  • capitalize
  • uppercase
  • lowercase

Currency

  • dollars
  • pennies

Datetime (WIP)

  • datepart
  • timepart
  • formatDatetime

Bolded helpers can be used for conditional templating blocks.

For example:

{{#gt age 30}}
You are old!
{{else}}
Such youth!
{{/gt}}

License

MIT

Keywords

FAQs

Last updated on 15 May 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc