handlebars-helper-maybe
Handlebars helpers for rendering optional values.
Installation
Install using npm:
$ npm install handlebars-helper-maybe
Usage
var Handlebars = ;var MaybeHelpers = ; Handlebars;Handlebars;
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