在 Rhino 上运行 CoffeeKup?
我正在尝试让 CoffeeKup 与 Mozilla 的 Rhino 引擎一起工作。到目前为止还没有太多运气。我正在尝试这个简单的模板:
templates ?= {}
templates.first = ->
doctype 5
html ->
head ->
title "#{@title}"
body ->
h1 "#{@hello}"
我编译成Javascript然后尝试使用渲染
CoffeeKup.render(templates.first, {title: 'Say Hello', hello: 'Hello World!'});
但它失败了:
org.mozilla.javascript.EcmaError: SyntaxError: invalid return (CoffeeKup#304(Function)#230)
在 Coffeekup.coffee 的 Javascript 版本中,第 304 行是这样的:
return new Function('data', code);
并且 code
第230行(最后一行)是这样的:
).call(data);return __ck.buffer.join('');
有什么东西看起来不寻常或者这可能是Rhino错误吗?
I'm trying to get CoffeeKup to work with Mozilla's Rhino engine. Not much luck so far. I'm trying this simple template:
templates ?= {}
templates.first = ->
doctype 5
html ->
head ->
title "#{@title}"
body ->
h1 "#{@hello}"
Which I compile into Javascript and then try to render using
CoffeeKup.render(templates.first, {title: 'Say Hello', hello: 'Hello World!'});
But it fails with this:
org.mozilla.javascript.EcmaError: SyntaxError: invalid return (CoffeeKup#304(Function)#230)
In the Javascript version of coffeekup.coffee, line 304 is this one:
return new Function('data', code);
And code
line 230 (last line) is this:
).call(data);return __ck.buffer.join('');
Does anything look out of the ordinary or is this perhaps a Rhino bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它适用于 Node/V8 + 浏览器但不适用于 Rhino,那么您可以相当确定它是特定于 Rhino 的东西(不过不一定是错误的)。在 coffeekup.coffee 顶部的较长评论中说它将在 Node 或浏览器上运行,所以很可能是这种情况。
要真正知道出了什么问题,您需要一个调试器,您可以在其中单步执行代码(我不知道如何在Rhino上执行此操作,可能通过Eclipse,甚至jdb(如果您手头有所有源代码并且非常精通 Java)。如果您发现一些合理的琐碎事情,请尝试提交问题,但 CoffeeKup 似乎没有过去几个月有很多活动。如果您准备迎接挑战,请分叉、修复并拉取请求。
If it works on Node/V8 + browsers but not Rhino, you can be fairly certain it's something specific to Rhino (not necessarily wrong, though). In the longer comment at the top of coffeekup.coffee it says that it will run on Node or on browsers, so that's most likely the case.
To really know what's going wrong, you need a debugger where you can step through the code (I don't know how to do that on Rhino, possibly via Eclipse or maybe even jdb if you have all sources at hand and are very Java proficient). If you find something reasonable trivial, try to file an issue, but CoffeeKup doesn't seem to have seen much activity for the last months. If you're up for a challenge, fork, fix and pull request.