1 – Method Chaining
I really love the way you can call functions without polluting your code with brackets, but the following inconsistency really bothers me;
$(this).attr("id").data "foo"
Method chaining like this pretty much requires me to use brackets up till the last method in the chain, this seems pretty inconsistent and makes my OCD sense tingle like crazy.. am I miss-understanding something here? Is there a more consistent but clean approach (ie. aside from reverting to using brackets everywhere).
2 – Compiler config?
I use coffee –watch to have it automatically compile the files, however the –help shows very few arguments I can give to change it’s behaviour. For one thing I’d like to change the tab size of the resulting javascript. Is there any way to do this?
1. Chaining
No, it really isn’t much cleaner than javascript, as far as syntax goes. And lots of people are complaining about it. I think you just have to bite the bullet and accept that you have to know javascript to use coffeescript, and that not all the warts of javascript are solved (yet, anyway). Personally I prefer the d3 or jQuery solution of judicious indenting:
2. Compiler config
There aren’t any configs apart from the ‘–bare’ options that I’m aware of. Buts its a compiler, not a formatter. You can send your compiled code all through JS Beautfy (or Uglify for that matter). If you plan on doing this, I highly recommend using a Cakefile. Check out this link for how you can work with the coffee compiler.