ember.js - Playframework 2.1 预编译 ember Handlebars

标签 ember.js playframework-2.0 handlebars.js rhino precompile

我正在尝试为 PlayFramework 2.1 编写一个 SBT 插件,它将预编译位于 app/assets/templates 中的 Handlebars 模板。我当然会在完成后分享这个插件。我找到了这个方法 http://eng.netwallet.com/2012/04/25/emberhandlebars-template-precompilation-with-play/这有点过时了,但将其改编为 Play 没有问题! 2.1.

然后我尝试编译一个简单的模板文件,但 SBT 失败了:

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

第 3309 行的 ember-1.0.0-pre.4.js 有一个 volatile 关键字,显然在 Rhino 中保留。

我远不是 Rhino 的专家,这就是为什么我想知道是否有人知道解决这个问题的方法?我现在不是在寻找 5* 解决方案。任何有合理机会适用于大多数简单 Handlebars 模板的解决方案(甚至是使用自定义 ember.js 的快速和肮脏的黑客)都可以工作,我们会担心一旦功能存在并且 SBT 插件出来后对其进行改进。

提前致谢!

最佳答案

我为 Grails 编写了一个等效的插件。如果我从 rhino 1.7R4 切换到 1.7R2,我会得到完全相同的错误。
你必须切换到 org.mozilla:rhino:1.7R4。

如果您遇到更多问题,我建议您查看我的源代码。您可以从这里开始:https://github.com/florent-blanvillain/grails-ember-templates-precompiler/blob/master/src/groovy/org/grails/plugin/ember/handlebars/Precompiler.groovy

干杯

关于ember.js - Playframework 2.1 预编译 ember Handlebars ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14856779/

相关文章:

node.js - 在express-handlebars中包含布局问题

jquery - 是否可以通过像 Handlebars 这样的模板库访问 jquery 函数?

javascript - 在 Rails API 中使用 Devise Token Auth gem 的不允许的参数

javascript - Ember mixins - 这是实现 'dynamic' 布局的好方法吗

ember.js - ember-cli 中 makeBoundHelper 和 registerBoundHelper 的区别

java - Swagger UI 和 Play 路由 *path

javascript - 如何在 Backbone 模型中放置按钮?

javascript - 在 Ember 中使用 AJAX 发布后没有文件下载

grails - Playframework - GSP 和标签库?

具有隐式参数的 Scala 设计模式(在 Scala 中 Play 2.x)