JJS
JJS

Reputation: 6658

How add custom handlebars helper in Stencil

The documentation indicates you can add a custom Handlebars Helper https://developer.bigcommerce.com/stencil-docs/handlebars-syntax-and-helpers/handlebars-overview#handlebars_custom

That conflicts with the code https://github.com/bigcommerce/paper-handlebars/blob/master/index.js#L69 that only loads helpers from the paper-handlebars module.

Is it even possible to define a custom Handlebars Helper, or should the documentation be updated?

Upvotes: 2

Views: 995

Answers (1)

Karen White
Karen White

Reputation: 2153

Looks like we need to tighten up the phrasing in the documentation to make that a little more clear (we've put a ticket in with the docs team). Thanks for the heads up.

It is true that you can add a custom Handlebars helper, but the caveat is that it has to be brought into the paper-handlebars module, where it would be available as part of Stencil. The process to add a new custom helper would be to submit a pull request to this repo:

https://github.com/bigcommerce/paper

Ideally, new helpers that we add to Stencil should be generic enough to apply to a lot of use cases.

Alternatively, we also pull in helpers from this library and whitelist certain helpers for Stencil:

https://github.com/helpers/handlebars-helpers

If you're working on a Helper that you think would benefit the wider Handlebars community, you can submit it to the handlebars-helpers repo and ask us to whitelist it in Stencil.

Upvotes: 2

Related Questions