Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
handlebars-subexpression-helpers
Advanced tools
Some simple yet useful subexpression helpers for handlebars
Some simple yet useful subexpression helpers for handlebars
From the Handlebars docs:
Handlebars offers support for subexpressions, which allows you to invoke multiple helpers within a single mustache, and pass in the results of inner helper invocations as arguments to outer helpers. Subexpressions are delimited by parentheses.
{{outer-helper (inner-helper 'abc') 'def'}}
In this case, inner-helper will get invoked with the string argument 'abc', and whatever the inner-helper function returns will get passed in as the first argument to outer-helper (and 'def' will get passed in as the second argument to outer-helper.
To make your life easier I created a set of simple and useful helpers for Handlebars which can exclusively be used as subexpression-helpers.
npm install handlebars-subexpression-helpers
Then you just need to require
the module and pass your Handlebars instance to the .register()
method:
var Handlebars = require('handlebars');
require('handlebars-subexpression-helpers').register(Handlebars);
Done. Now you can use all of the included helpers.
<p>Manuel – Status: {{#if (isEqual user.status 'unconfirmed') }} Not yet activated {{else}} Active {{/if}}</p>
If you don't need all helpers you can also require single helpers. All of them export a register()
method which expect your Handlebars instance to be passed:
var Handlebars = require('handlebars');
require("handlebars-subexpression-helpers/dist/lib/helpers/is-array").register(Handlebars);
require("handlebars-subexpression-helpers/dist/lib/helpers/typeof").register(Handlebars);
For a complete list, have a look at dist/lib/helpers.
While the filename is separated by dashes, the helper name itself is camelCase. So is-array.js
can be used as isArray
for example.
FAQs
Some simple yet useful subexpression helpers for handlebars
The npm package handlebars-subexpression-helpers receives a total of 13 weekly downloads. As such, handlebars-subexpression-helpers popularity was classified as not popular.
We found that handlebars-subexpression-helpers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.