We're building an Ember/Java application and we're using Rhino during our maven build to precompile our Handlebars templates. Up until today we were using Handlebars RC3 and Ember RC3, and life was good. Today we tried to update to Ember RC6 and Handlebars 1.0.0, and now our Rhino precompiler gives this:
js: "src/main/js/third-party/handlebars-1.0.0.js", line 2024: uncaught JavaScript runtime
exception: TypeError: Cannot call method "replace" of undefined
at src/main/js/third-party/handlebars-1.0.0.js:2024
at src/main/js/third-party/handlebars-1.0.0.js:2038
at src/main/js/third-party/handlebars-1.0.0.js:1747
at src/main/js/third-party/handlebars-1.0.0.js:1368
at src/main/js/third-party/handlebars-1.0.0.js:1860
at src/main/js/third-party/handlebars-1.0.0.js:1356
at src/main/js/third-party/handlebars-1.0.0.js:1860
at src/main/js/third-party/handlebars-1.0.0.js:1356
at src/main/js/rhino-handlebars-precompiler.js:75 (precompile)
at src/main/js/rhino-handlebars-precompiler.js:89 (init)
at src/main/js/rhino-handlebars-precompiler.js:93
at src/main/js/rhino-handlebars-precompiler.js:15
We've tried both our own flavor of Rhino compiler and the one found here: https://github.com/locnguyen/ember-rhino-precompiler.
Update
After looking deeper into Handlebars, it seems that Handlebars-1.0.0 is producing slightly different opcodes than Handlebars RC3, in particular it's missing a call to the _triageMustache helper. For this handlebars fragment:
{{#if enableLinks}}<a href="/foo?userId={{unbound loginAsAdminId}}&userAsId={{unbound legacyUserId}}" id="logoutAsLink">Return to {{loginAsAdminName}}</a>{{/if}}
With RC3 we get this:
in compile appendContent "<a href="/userportal/returnToAdmin?userId="
getContext 0
pushStringParam "loginAsAdminId" "ID"
pushProgram
pushProgram
emptyHash
invokeKnownHelper 1 "unbound"
appendEscaped
appendContent "&userAsId="
getContext 0
pushStringParam "legacyUserId" "ID"
pushProgram
pushProgram
emptyHash
invokeKnownHelper 1 "unbound"
appendEscaped
appendContent "" id="logoutAsLink">Return to "
getContext 0
pushStringParam "loginAsAdminName" "ID"
pushProgram
pushProgram
emptyHash
invokeKnownHelper 1 "_triageMustache"
appendEscaped
appendContent "</a>"
With 1.0.0, we get this:
in compile appendContent "<a href="/userportal/returnToAdmin?userId="
getContext 0
pushStringParam "loginAsAdminId" "ID"
pushProgram
pushProgram
emptyHash
invokeKnownHelper 1 "unbound"
appendEscaped
appendContent "&userAsId="
getContext 0
pushStringParam "legacyUserId" "ID"
pushProgram
pushProgram
emptyHash
invokeKnownHelper 1 "unbound"
appendEscaped
appendContent "" id="logoutAsLink">Return to "
getContext 0
pushStringParam "loginAsAdminName" "ID"
pushProgram
pushProgram
emptyHash
invokeHelper 1
appendEscaped
appendContent "</a>"
Note that the last call to invokeHelper is missing the helper name. That's where things are falling down. I don't know handlebars well enough yet to figure out why it's missing that.
Thanks, Scott