CoffeeKup Rails: An asset pipeline engine for cofeekup

I have been in the process of developing yet another client side MVC framework. This one in particular in coffreescript and targeting Rails integration. I will have more on that as things progress. This gem grew out of my need to treat coffeekup template files as first class citizens in the asset pipeline. The coffeekup node command is lacking in regards to directory watching and I wanted an experience identical to asset pipeline compilation for coffee or jst files. Enter coffeekup_rails.

How it’s used

Say your client side views live in /app/assets/javascripts/views (default).

Given /app/assets/javascripts/views/shared/hello.js.ck:

h1 "Hello \#{@name}."
      

CoffeeKup will automatically compile the coffeescript source to a coffeekup javascript template under a desired global js object (defaults to window.templates). Template names are period delimited by directory structure. From the javascript console:

templates['shared.hello']({name: 'chris'})
          => "<h1>Hello chris.</h1>"
      

This happens upon every page load when your .ck files change thanks to sprockets and the asset pipeline just as you would expect for a .coffee file. For installation instructions, configuration, and more, check the github project page.

Comments