Hello,
This caused me a lot of headache.
During rewriting an old Grails project i used the same JavaScript code for my handlebars calls as in the old one.
It worked fine, but as soon as i deployed the project on a test server i got always a JavaScript type error : "TypeError: Handlebars.Template is not a function".
I tried a couple of things until i could discover why the code is working on localhost in the development mode but not on any other deployment stage.
Maybe the problem is related to: https://stackoverflow.com/questions/64632219/grails-run-app-services-javascript-starting-with-node-env-line
the code: var hbTemplate = Handlebars.templates['handlebars/example'] is working fine.
Runing the project on the test or prod environment, where all the JavaScript assets are merged into one file, the above code is not working anymore. But instread that this code is working: var hbTemplate = Handlebars.templates.example;
I added then developmentRuntime = false to the asset {} part in my build.gradle so that I got alle the JavaScript assets merged into one file while the application was still running in the dev environment.
With that the first code stopped working and the second one started working instead.
This is why I am thinking, that there is a bug how the asset pipe line is working with developmentRuntime = true/false
Example Application
https://github.com/DontPlayTheGame/assetpipeline-grails406
I included both typ of JavaScript code in the example. You can run the applikation in development environment and then just add developmentRuntime = false to the asset {} in your build.gradle or run the applcation with grails.env=test or grails.env=prod
Hello, This caused me a lot of headache. During rewriting an old Grails project i used the same JavaScript code for my handlebars calls as in the old one. It worked fine, but as soon as i deployed the project on a test server i got always a JavaScript type error : "TypeError: Handlebars.Template is not a function". I tried a couple of things until i could discover why the code is working on localhost in the development mode but not on any other deployment stage. Maybe the problem is related to: https://stackoverflow.com/questions/64632219/grails-run-app-services-javascript-starting-with-node-env-line
Environment Information
Actual Behaviour
build.gradle:
As long as I am runing a project in devlopment environment and alle the JavaScript assets are separeted like this:
the code:
var hbTemplate = Handlebars.templates['handlebars/example']
is working fine.Runing the project on the test or prod environment, where all the JavaScript assets are merged into one file, the above code is not working anymore. But instread that this code is working:
var hbTemplate = Handlebars.templates.example;
I added then
developmentRuntime = false
to theasset {} part
in my build.gradle so that I got alle the JavaScript assets merged into one file while the application was still running in the dev environment. With that the first code stopped working and the second one started working instead.This is why I am thinking, that there is a bug how the asset pipe line is working with developmentRuntime = true/false
Example Application
https://github.com/DontPlayTheGame/assetpipeline-grails406 I included both typ of JavaScript code in the example. You can run the applikation in development environment and then just add
developmentRuntime = false
to theasset {}
in your build.gradle or run the applcation with grails.env=test or grails.env=prod