Making Custom Helpers in Assemble using RequireJS's amdefine work for a web-based project

265 Views Asked by At

So I have this project where I use Assemble (http://assemble.io/docs/) as my static site generator, and I have made a couple of customer handlebars helpers (http://assemble.io/docs/Custom-Helpers.html) to use when assembling my pages.

This all works fine, I reference the helper file within my grunt task, runs a "grunt serve" and voila, my assembled handlebars files are now using my new custom helper.

However... In my project I also have some handlebars templates files that are not used through Assemble. These templates are being precompiled and used when I e.g. want to update the product basket on my website, and these web-based templates should also be able to use my custom helpers.

The code for my handlebars helpers:

module.exports.register = function (Handlebars, options, params) {
  // Helper goes here.
};

How would I go on with RequireJS's amdefine in order to be able to use these helpers in my web-based project.

Br Dan

1

There are 1 best solutions below

0
On

This is a big focus for the v0.6.0 release of handlebars-helpers, you should be able to accomplish what you want with that release.

There is also an existing issue on that repo to discuss: https://github.com/assemble/handlebars-helpers/issues/36, feel free to add your thoughts!