benrady/modit — Issue #2: coffeescript incompatibility
Author: amirrajan
Created: 2011-10-17 00:22:50+00:00
State: open

coffeescript does not allow for function declarations and I'm unsure of how to use it with modit given that.

for example, a valid module looks like the following in javascript:

modit('foobar', function() {
function init() {
alert('works');
}

this.exports(init);
}

you cannot generate the code above using coffeescript, follows is the coffeescript i used and the resulting javascript output:

//coffee script
modit 'foobar', () ->
init = (urls) -> alert('works')

this.exports(init)

//compiles to
(function() {
modit('foobar', function() {
var init;
init = function(urls) {
return alert('works');
};
return this.exports(init);
});
}).call(this);

I've tried different variations with no luck:

modit 'foobar', () ->
init: (urls) -> alert('works')

this.exports(init)

(function() {
modit('foobar', function() {
({
init: function(urls) {
return alert('works');
}
});
return this.exports(init);
});
}).call(this);