Thursday Night

Paul Betts’s personal website / blog / what-have-you

Announcing: SassAndCoffee 0.5

Sass and Who What Now?

One of the new controversial features that is being added to the latest version of Rails, is the default inclusion of two languages that make web development easier – one for simplifying CSS called “Sass”, and a language for writing more readable, elegant Javascript, which is called CoffeeScript. The examples from these two sites illustrate the languages far better than I could.

Both of these languages share some common characteristics – they both try to generally stay “true” to their target language (i.e. CoffeeScript compiles down to clean, readable JavaScript that generally has a 1:1 mapping from source to target statement), and they both attempt to solve some of the historical “ugliness” associated with their target language. I’ve used both Sass and CoffeeScript before in the past and I think they are a brilliant contribution to web development, and allow you to write cleaner, more reusable code.

These two languages have excellent support in Rails, as well as in node.js, two of the latest “hip” web development platforms, and I was surprised that someone hadn’t beaten me to the punch and created NuGet packages to enable support for these – a lot of people had solutions for different pieces, but most were proof-of-concepts or were difficult to use. With NuGet, there is zero reason that web libraries should be anything other than “one-click install”.

So without further ado, I present, SassAndCoffee – an ASP.NET library to add drop-in support for Sass/SCSS and CoffeeScript!

How to use SassAndCoffee

  • Add the package reference via NuGet
  • Add a .coffee, .scss, or .sass file to your project (an easy test is to just rename a CSS file to .scss)
  • Reference the file as if it was a CSS or .JS file (i.e. to reference “scripts/”, you should reference “scripts/test.js” in your SCRIPT tag)

That’s all there is to it! Files will be cached in your AppData folder and will be regenerated whenever you modify them.

How does it work?

SassAndCoffee embeds the original compilers in the DLL as (Sass 3.2.0 and CoffeeScript 1.1.0 as of this writing) and uses IronRuby and Jurassic respectively to execute the compilers against your source.

Why is this better than [SOMEOTHERPROJECT]

  • No external processes are executed
  • You don’t have to install Ruby or node.js
  • It’s in NuGet so you don’t have to fiddle with web.config
  • Files are cached and are rebuilt as-needed.


Several folks helped me out with some of the integration details of this project – if it weren’t for them, I would still be stuck in the mud right now:

  • David Padbury for helping me out with the CoffeeScript compiler
  • Levi Broderick for giving me a few hints as to how to rig up the HttpModule
  • Jimmy Schementi for telling me the proper way to redirect ‘requires’ to an embedded resource

Written by Paul Betts

May 16th, 2011 at 2:33 am