nilskp
nilskp

Reputation: 3127

Running CoffeeKup on 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?

Upvotes: 2

Views: 237

Answers (1)

Jacob Oscarson
Jacob Oscarson

Reputation: 6403

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.

Upvotes: 1

Related Questions