-
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
Handlebars uses "default" with the AMD option #667
Comments
Never mind, messed up my understanding of what is going on |
This is the expected behavior as the amd module exports a default field to keep parity with the ES6 module transitional behavior. Glad to chat about specific errors if you create a fiddle demonstrating the issue though! |
It did not work. "default" is null for me. When I delete the reassignment of the Handlebars variable it works. It seems to me that there is an incorrect assumption that must not be true in my environment. Is there an assumed version of Require.js and perhaps mine is too old? Am I supposed to be using a different version of handlebars.runtime.js besides the one from the main download link? I got it from: |
You need to use one of the amd builds if you are going to compile the templates to amd using the bundled CLI precompiler. Ex: //cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.1.2/handlebars.runtime.amd.js The bundled precompiler does not attempt to handle mixed modes where some things are defined and loaded via AMD and others are not. |
I'm not sure how the AMD version is supposed to work (full, not runtime). See this fiddle: Why is everything attached to default and how do I fix this without calling Handlebars["default"] everywhere? |
@wycats can you provide more info on |
Have we any other solutions beside manually add |
@chuwy https://gist.github.com/wycats/7417be0dc361a69d5916 might help you out. |
No, it doesn't helped. I think, I chose wrong issue for asking help. |
@chuwy the default return is expected. If you're seeing a failure with the runtime version then filing another issue with a jsfiddle that reproduces the issue is the best way for us to look into the issue. |
I realize this is closed but for clarity, I added a new JSFiddle at http://jsfiddle.net/RyanBlunden/zth1f501/ which shows how to use the Handlebars AMD Runtime with RequireJS. |
Thanks for the fiddle ryan, but how would someone do this when their templates are created via someting like grunt-contrib-handlebars? Edit: found this #796 (comment) |
I don't know as this is an issue with grunt-contrib-handlebars. This is precisely why I'm not a fan of using Grunt for trivial tasks such as rendering Handlebars templates. To see how easy it is, checkout the script at https://github.com/ryan-blunden/handlebars-requrejs/blob/master/project/bin/compile_templates_amd.sh |
Having the same issues when trying to include Handlebars in karma tests. |
Use grunt-replace task to fix this issue: match: /function(Handlebars) {/g, src: ['*/**/hbs.js'], |
With handlebars.js version 1.1.2 the "handlebars --amd" option now creates invalid templates.
The code has this:
I'm not seeing any "default" property of handlebars. The code would be fine if the assigning to Handlebars["default"] was not used.
Here is how I'm loading handlebars 1.1.2 so that it is correctly exported:
Is there something different that must be done with v1.1.2?
The text was updated successfully, but these errors were encountered: