v1.1.2
This release improves integration with downstream platforms (for example HubSpot) by letting
projects register their own Handlebars helpers during preview generation, instead of relying
only on Handoff’s built-in field and eq helpers.
Feature
hooks.registerHandlebarsHelpers — New optional hook in handoff.config.js. After Handoff
registers its default preview helpers, your callback runs with the Handlebars runtime, the
current componentId, the component properties (slot metadata), and a flag for inspect-mode
renders (injectFieldWrappers). Use handlebars.registerHelper (and block helpers as needed)
to add helpers that are only available while building component preview HTML—so templates can
stay platform-specific without forking Handoff.
Typical uses: block helpers that wrap regions meant for a host page’s header or footer, or a
helper that serializes a value as JSON for inline scripts. Those behaviors are not shipped
as core helpers; you define them in config so each project controls naming and semantics.
See docs/api.md (Hooks → registerHandlebarsHelpers) for the full signature and README
“Configuration hooks” for a quick pointer.
Example: JSON in templates
If you register a json helper in hooks.registerHandlebarsHelpers, like this
hooks: {
registerHandlebarsHelpers: ({ handlebars, componentId }) => {
// Register 'json' as a simple (non-block) helper
handlebars.registerHelper('json', (value, data) => {
return new handlebars.SafeString(JSON.stringify(value, null, 2));
});
}
}
Then your templates can do:
<script type="text/javascript">
window.barChartData = {{{json properties.data}}};
</script>
with output shaped by your helper implementation (for example serialized JSON for chart data).
Changes
- Merge pull request #240 from Convertiv/release/1.1.2 11e5011
- Enhance error handling in registerHandlebarsHelpers function f600e7f
- Update package-lock.json 38e0771