Gathering detailed insights and metrics for handlebars-utils
Gathering detailed insights and metrics for handlebars-utils
Gathering detailed insights and metrics for handlebars-utils
Gathering detailed insights and metrics for handlebars-utils
@transcend-io/handlebars-utils
Utility functions for handlebars templating with Transcend - available in node and client side.
codegen-handlebars-utils
Handlebars utils for GraphQL Codegen templates
agilite-utils
Various 3rd party utilities, functions and services that we simplify and use throughout the Agilit-e ecosystem
html-tag-helpers
Easily generate helpers for creating HTML tags. Works great as handlebars helpers or vanilla javascript utils.
Utils for handlebars helpers. Externalized from handlebars, to allow helpers to use the utils without having to depend on handlebars itself.
npm install handlebars-utils
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
7 Stars
29 Commits
5 Forks
2 Watchers
1 Branches
3 Contributors
Updated on Jul 03, 2020
Latest Version
1.0.6
Package Id
handlebars-utils@1.0.6
Size
6.63 kB
NPM Version
5.5.1
Node Version
9.1.0
Published on
Nov 17, 2017
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
3
Utils for handlebars helpers. Externalized from handlebars, to allow helpers to use the utils without having to depend on handlebars itself.
Follow this project's author, Jon Schlinkert, for updates on this project and others.
(TOC generated by verb using markdown-toc)
Install with npm:
1$ npm install --save handlebars-utils
1var utils = require('handlebars-utils');
Returns true if a helper is a block helper.
Params
options
{Object}: Helper options objectreturns
{Boolean}Example
1Handlebars.registerHelper('example', function(options) {
2 if (utils.isBlock(options)) {
3 // do something if this is a block helper
4 } else {
5 // do something else if this is a not block helper
6 }
7});
Returns the given value or renders the block if it's a block helper.
Params
val
{any}options
{Object}context
{Object}returns
{String}: Either returns the value, or renders the block.Example
1Handlebars.registerHelper('example', function(val, locals, options) {
2 return utils.fn(val, locals, options);
3});
Returns the given value or renders the inverse block if it's a block helper.
Params
val
{any}options
{Object}context
{Object}returns
{String}: Either returns the value, or renders the inverse block.Example
1Handlebars.registerHelper('example', function(val, locals, options) {
2 return utils.inverse(val, locals, options);
3});
Gets the return value for a helper, by either rendering the block or inverse block if it's a block helper, or returning the given value (when truthy) or an empty string (when falsey) if it's a non-block expression.
Params
val
{any}options
{Object}context
{Object}returns
{String}Example
1Handlebars.registerHelper('example', function(val, locals, options) {
2 return utils.value(val, locals, options);
3});
Returns true if the given value is a handlebar options
object.
Params
val
{Object}returns
{Boolean}Example
1Handlebars.registerHelper('example', function(val, locals, options) {
2 if (utils.isOptions(locals)) {
3 options = locals;
4 locals = {};
5 }
6 // do stuff
7});
Returns true if the given value is undefined
or is a handlebars options hash (which means that a value was not passed by the user).
Params
value
{any}returns
{Boolean}Example
1Handlebars.registerHelper('example', function(val, options) {
2 if (utils.isUndefined(val)) {
3 return '';
4 }
5 // do stuff
6});
Returns true if an app
propery is on the context, which means the context was created by assemble, templates, verb, or any other library that follows this convention.
Params
value
{any}returns
{Boolean}Example
1Handlebars.registerHelper('example', function(val, options) {
2 var context = options.hash;
3 if (utils.isApp(this)) {
4 context = Object.assign({}, this.context, context);
5 }
6 // do stuff
7});
Creates an options object from the context
, locals
and options.
Handlebars' options.hash
is merged onto the options, and if the context
is created by templates, this.options
will be merged onto the
options as well.
Params
context
{Object}locals
{Object}: Options or localsoptions
{Object}returns
{Boolean}Get the context to use for rendering.
Params
thisArg
{Object}: Optional invocation context this
returns
{Object}Returns true if the given value is an object.
Params
val
{Object}returns
{Boolean}Example
1console.log(utils.isObject(null)); 2//=> false 3console.log(utils.isObject([])); 4//=> false 5console.log(utils.isObject(function() {})); 6//=> false 7console.log(utils.isObject({})); 8//=> true
Returns true if the given value is "empty".
Params
value
{any}returns
{Boolean}Example
1console.log(utils.isEmpty(0)); 2//=> false 3console.log(utils.isEmpty('')); 4//=> true 5console.log(utils.isEmpty([])); 6//=> true 7console.log(utils.isEmpty({})); 8//=> true
Returns the given value. If the value is a function it will be called with the current context, otherwise the value is returned.
Params
val
{any}returns
{any}Example
1console.log(utils.result('foo')); 2//=> 'foo' 3console.log(utils.result(function() { 4 return 'foo'; 5})); 6//=> 'foo'
Returns the given value as-is, unchanged.
Params
val
{any}returns
{any}Example
1console.log(utils.result('foo')); 2//=> 'foo' 3console.log(utils.result(function() { 4 return 'foo'; 5})); 6//=> [function]
Return true if val
is a non-empty string.
Params
val
{any}: The value to checkreturns
{Boolean}Cast the given val
to an array.
Params
val
{any}returns
{Array}Example
1console.log(utils.arrayify('')); 2//=> [] 3console.log(utils.arrayify('foo')); 4//=> ['foo'] 5console.log(utils.arrayify(['foo'])); 6//=> ['foo']
Try to parse the given string
as JSON. Fails
gracefully and always returns an object if the value cannot be parsed.
Params
string
{String}returns
{Object}You might also be interested in these projects:
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the contributing guide for advice on opening issues, pull requests, and coding standards.
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
1$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
1$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on September 04, 2017.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 1/28 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More