javascriptnode.jsexpresscoffeescriptlocomotivejs

How do I set coffescript in Locomotivejs?


What should I do to set coffeescript in Locomotivejs.

It seems very easy, but I couldn't figure that out.

I set options in "all.js", without luck.

I think I'm almost there or very far to get it right. :(

this.set("options",{coffee:true});

Any help is appreciated.


Solution

  • You'll want to add a server.js file and boot Locomotive with CoffeeScript support, like so:

    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);
      )
    )
    

    To start the app:

    $ node server
    

    There's more info in this pull request: https://github.com/jaredhanson/locomotive/pull/44

    Support for a --coffee option to the lcm command line will be added to an upcoming release.