This is a response to something nobody's saying.
Obviously if they write it they get to choose pretty much everything about it. Nobody is disputing such a thing.
However, if one of the goals in releasing this is to be maximally useful, isn't the fact that raw Javascript is more readily understandable to more people a good thing to point out? Especially since it's highly likely that the team actually has the ability to do normal JS just as easily.
If they disagree with such a goal, though, they can feel free to do whatever they want.
http://jashkenas.github.com/coffee-script/#classes
If they showed JS examples it would instantly turn everyone off. Trust me, you do NOT want to use this with JS.
Or maybe more accurately a speech in modern English to a group of early modern English speakers.
Right... "alternative"... so makes sense to not give examples entirely in it unless your framework is intended solely for Coffeescript users.
(function() {
var Shopify;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
Shopify = (function() {
function Shopify() {
Shopify.__super__.constructor.apply(this, arguments);
}
__extends(Shopify, Batman.App);
Shopify.root('products#index');
Shopify.resources('products');
return Shopify;
})();
Shopify.Product = (function() {
function Product() {
Product.__super__.constructor.apply(this, arguments);
}
__extends(Product, Batman.Model);
Product.persist(Batman.RestStorage);
return Product;
})();
Shopify.ProductsController = (function() {
function ProductsController() {
ProductsController.__super__.constructor.apply(this, arguments);
}
__extends(ProductsController, Batman.Model);
ProductsController.prototype.index = function() {
return this.redirect({
action: 'show',
id: 1
});
};
ProductsController.prototype.show = function(params) {
return this.product = Shopify.Product.find(params.id);
};
return ProductsController;
})();
}).call(this); var Shopify = Batman.App.extend()
Shopify.root('products#index')
Shopify.resources('products')
Shopify.Product = Batman.Model.extend()
Shopify.Product.persist(Batman.RestStorage)
// I'm never sure about how much I'm expected to mimic CoffeeScript code
// when using libraries written in CoffeeScript and the source code is
// written in a language I'm not practiced at reading - I've been bitten in
// the past by CoffeeScript-only examples which *assume* you're transpiling
// to JS in your head to insert the implicit return of the result of the
// last expression.
Shopify.ProductsController = Batman.Controller.extend({
index: function() {
return this.redirect({action: 'show', id: 1})
}
, show: function(params) {
return this.product = Shopify.Product.find(params.id)
}
})
If there's common boilerplate associated with each constructor, you could also go further and customise the extend method for each one to take care of it if provided with certain configuration details, e.g.: var Shopify = Batman.App.extend({
root: 'products#index'
, resources: 'products'
})
It always puzzles me that people look at some of the implementation details CoffeeScript shields programmers from and throw their hands up in the air and admit defeat [2] when we have a language as flexible as JavaScript at our disposal to hide some of the uglier implementation details in APIs we define.[1] https://github.com/documentcloud/backbone/blob/master/backbo...
They wrote you a nice library and are giving it away under an MIT license. You don't get to pick the style they use to write the examples. That's like going to a science lecture and walking up to the speaker afterwards to say, "Hey, I think you have some great theories, but you really should lose that Australian accent of yours. Most scientists aren't from Australia, you know."