1.0.0 • Published 9 years ago
handlebars-helper-maybe v1.0.0
handlebars-helper-maybe
Handlebars helpers for rendering optional values.
Installation
Install using npm:
$ npm install handlebars-helper-maybeUsage
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
1.0.0
9 years ago