jaredhanson/locomotive — pull request #44 by djensen47 (2012-09-17 04:57:29+00:00)
Title: CoffeeScript support

Since CoffeeScript is quite popular with many Node.js developers, it seemed like a shame that Locomotive did not include CoffeeScript support.

This pull request adds simple CoffeeScript support. When you invoke locomotive.boot, you include a new option "coffeeScript" as a boolean to enable it. If enabled, the functions that invoke the config, initializers, and controllers will also look for the .coffee extension.

This integration assumes that the called has already invoked ```require("coffee-script")```.

More CoffeeScript integration could be introduced in the future as needed/desired.

Right now I'm calling my CoffeeScript Locomotive app with the following code:

**start.js**

require('coffee-script');
require('./server');

**server.js**

locomotive = require('locomotive')

locomotive.boot('.', 'development', {"coffeeScript": true}, (err, server) ->
throw err if (err)

server.listen(3000, 'localhost', ()->
addr = this.address()
console.log('listening on %s:%d', addr.address, addr.port);
)
)

I start the server with the following from the command line:

$ node start