modit
modit copied to clipboard
coffeescript incompatibility
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);
here is an additional link that may help clarify http://stackoverflow.com/questions/6548750/function-declaration-in-coffeescript