5

I'm trying to write an SBT plugin for PlayFramework 2.1 which would precompile handlebars templates located in app/assets/templates. I will of course share this plugin when it is complete. I found this howto http://eng.netwallet.com/2012/04/25/emberhandlebars-template-precompilation-with-play/ which was a little outdated, but it was no problem adapting it for Play! 2.1.

Then I tried to compile a simple template file, but SBT failed with the following:

ember: processing template test

[error] /.../templates/test.handlebars: Compilation error[unexpected exception during Ember compilation (file=/.../templates/test.handlebars, options=List(), ember=ember-1.0.0-pre.4.js): org.mozilla.javascript.EvaluatorException: missing name after . operator (ember-1.0.0-pre.4.js#3309)]

[error] (MyProject/*:play-copy-assets) @6dap83075: Compilation error in /.../templates/test.handlebars:null

[error] (MyProject/compile:resources) @6dap83075: Compilation error in /.../templates/test.handlebars:null

ember-1.0.0-pre.4.js at line 3309 has a volatile keyword, which is apparently reserved in Rhino.

I'm far from an expert in Rhino, which is why I'm wondering if someone knows of a way to work around this? I'm not looking for a 5* solution right now. Any solution (even quick and dirty hacks like using a custom ember.js) that has a reasonable chance of working for most simple handlebars templates would work and we'd worry about polishing it once the functionality is there and the SBT plugin is out.

Thanks in advance!

user510159
  • 1,379
  • 14
  • 26

3 Answers3

0

I wrote an equivalent plugin for Grails. I get the exact same error if I switch from rhino 1.7R4 to 1.7R2. You have to switch to org.mozilla:rhino:1.7R4.

If you encounter further issues, I suggest you take a look at my source code. You can start here: https://github.com/florent-blanvillain/grails-ember-templates-precompiler/blob/master/src/groovy/org/grails/plugin/ember/handlebars/Precompiler.groovy

Cheers

0

This is due to ember using the keyword volatile which is reserved for rhino, as it conforms to JavaScript EC3. Setting rhino to use EC5 has no effect

See https://github.com/emberjs/ember.js/issues/1202

This is even worse in ember-1.0.rc1 as they are using other reserved keywords. A solution is to do a custom ember.js file with those keywords renamed

Krumpi
  • 125
  • 1
  • 8
0

My plugin for ember precompilation in play 2.1 is working. It supports ember-1.0.0-pre.2, ember-1.0.0-rc.1 and ember-1.0.0-rc.3 and works around the issues related to rhino.

See https://github.com/krumpi/play-emberjs

Krumpi
  • 125
  • 1
  • 8