mikeal / node.couchapp.js

Utility for writing couchapps.
Apache License 2.0
406 stars 78 forks source link

Coffeescript support #25

Open josephg opened 12 years ago

josephg commented 12 years ago

It would be way rad if node.couchapp supported coffeescript.

max-mapper commented 12 years ago

Interesting suggestion. The only javascript you have to write lives in the couchapp files themselves (e.g. https://github.com/mikeal/node.couchapp.js/blob/master/boiler/app.js) which isn't very much javascript at all. I don't really see how coffeescript would make writing couchapps any easier but I would be interested to hear why you would prefer it over javascript in this context.

josephg commented 12 years ago

I prefer coffeescript in general - I prefer it because its better than javascript :)

Eg:

ddoc.views =
    conflicts:
        map: (doc) ->
            emit doc._conflicts, null if doc._conflicts

I guess I've been writing giant coffeescript apps, and views are (in comparison) very small pieces of code. Still, supporting coffeescript in couchapp should be dead simple. Adding require('coffee-script'); at the top of bin.js would let you require('./my-app.coffee').

... I'll make a pull request :p

gr2m commented 12 years ago

I've a fork with coffeescript support, not only for app.js, but for all its assets. They get compiled seamlessly when pushing to couch. I've also added optional concatenation & compression for js/css github.com/gr2m/node.couchapp.js

It's quite hacky, but if there is interest and if Max likes the API, I'd be happy make it vanilla so everybody can benefit

jprichardson commented 12 years ago

I was really interested in node.couchapp until I found out that it doesn't support CoffeeScript. I'd like to see it pulled in the main branch.