-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading pre-compiled templates is broken when using AMD and v1.1 #563
Comments
If your templates are precompiled, you just need to require the js file and
|
Yeah. Exactly. But the pre-compiled template syntax does not use AMD. |
There is an amd flag for that. This is the command that I normally use Handlebars templates/>pagetemplates.js -a -e html This is supported in the latest precompiler. Some options are not in the
|
Good. I'll try it. So it could be a documentation issue. There should be some note in the changelog or docs explaining the steps necessary to move to full AMD support. |
@zvikico Did the flag work for you? |
Yes, it does. I'm glad to see AMD support is being introduced to Handlebars.js. I've been a huge fan of require.js for a long time now and this is a very important step for Handlebars. Still, it means that 1.1 won't be a drop-in replacement for many people out there. That's something to consider. |
Heads up: under 1.1 we moved to ES6 modules which now require |
Released in 1.1.0 |
In the current master, v1.1, the library loading is adapted to using AMDs (I use require.js). When using an require.js, for example, the Handlebars is no longer a global var. This works OK if you've used require.js properly, since you are supposed to start your module with a block that looks like this:
This works well. But, compiled templates are not defined that way. The code assumes templates are global. Here's a sample code I use:
The helper registration works, because Handlebars is defined. However, the templates loading failed because it is not. I could add something like:
And that would fix the problem. But that's not really backwards compatible...
The text was updated successfully, but these errors were encountered: