【发布时间】:2012-01-03 23:45:07
【问题描述】:
我正在尝试让 CoffeeKup 与 Mozilla 的 Rhino 引擎一起工作。到目前为止没有多少运气。我正在尝试这个简单的模板:
templates ?= {}
templates.first = ->
doctype 5
html ->
head ->
title "#{@title}"
body ->
h1 "#{@hello}"
我compile into Javascript然后尝试使用渲染
CoffeeKup.render(templates.first, {title: 'Say Hello', hello: 'Hello World!'});
但它失败了:
org.mozilla.javascript.EcmaError: SyntaxError: invalid return (CoffeeKup#304(Function)#230)
在 Javascript 版本的 coffeekup.coffee 中,第 304 行是这一行:
return new Function('data', code);
code 第 230 行(最后一行)是这样的:
).call(data);return __ck.buffer.join('');
有什么不寻常的地方吗?或者这可能是 Rhino 的错误?
【问题讨论】:
-
您确定您链接的代码在 Node 中也可以工作吗?它为我提供了“...”辅助提示,就像它正在等待更多输入一样,它也会在 Spidermonkey 中引发 SyntyxError。
-
我不使用 Node,所以没有。但即使在我看来它看起来不错,但这并不意味着那里没有微妙的错误。如果您简化它或进行任何修改,您是否能够让 Node 使用它?
-
我创建了this HTML file,在 Firefox 中查看时,警报内容为:
<!DOCTYPE html><html><head><title>Say Hello</title></head><body><h1>Hello World!</h1></body></html>,因此代码看起来没问题。
标签: javascript coffeescript rhino coffeekup