handlebars-helper-maybe

1.0.0 • Public • Published

handlebars-helper-maybe

Handlebars helpers for rendering optional values.

npm Version Build Status Test Coverage Dependency Status

Installation

Install using npm:

$ npm install handlebars-helper-maybe

Usage

var Handlebars = require('handlebars');
var MaybeHelpers = require('handlebars-helper-maybe');
 
Handlebars.registerHelper('isJust', MaybeHelper.isJust);
Handlebars.registerHelper('maybe', MaybeHelper.maybe);

Helpers

{{#isJust}}

Block helper that renders the block if the given value is a Just. If an inverse block is specified, it will be rendered if the value is a Nothing.

Example

{{#isJust value}}
  Just {{this}}
{{else}}
  Nothing
{{/isJust}}

{{maybe}}

Returns the value inside the Maybe. If the argument is a Nothing and the defaultValue option is specified, this will return the provided default value. Otherwise it will return undefined.

Example

{{maybe value defaultValue="Not Available"}}

Related

What's a Maybe?

Known Supported Maybe Implementations

License

MIT

Package Sidebar

Install

npm i handlebars-helper-maybe

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jimf