HTTP Caching SASS for your leisure (?)
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
features s/Rack/Rails Oct 16, 2009
.gitignore Adding Jeweler into the mix Oct 16, 2009
LICENSE Trying to make this look legitimate Oct 16, 2009
README.textile Adding install info too Oct 16, 2009
Rakefile Fixing the haml dependency Oct 16, 2009
VERSION Fixing the haml dependency Oct 16, 2009
init.rb Use Hassle instead Oct 15, 2009



Making SASS less of a hassle on read only filesystems. (like Heroku)


Get it from Gemcutter.

gem install hassle -s


By default, SASS compiles CSS into the public/ directory. On platforms like Heroku, this won’t work. Instead, Hassle compiles the SASS for you into tmp/ and serves it up via a Rack::Static middleware.

Hassle assumes a few basic things about your setup: There’s going to be a tmp/ directory where it can write to, and public/ is where you store your css. A simple example:

$ tree
|-- public
|   `-- stylesheets
|       `-- sass
|           `-- application.sass
`-- tmp
    `-- hassle
        `-- stylesheets
            `-- application.css

With a basic SASS file in public/stylesheets/sass/application.sass, you can include it in your views with:

<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />

Hassle will look at the default sass directory (public/stylesheets/sass) and other input directories given in Sass::Plugin.options[:template_location]. CSS files are then compiled into tmp/ one directory higher than where you specified. Here’s a small example of customization:

Sass::Plugin.options[:template_location] = "./public/css/templates"

And after Hassle runs…

$ tree
|-- public
|   `-- css
|       `-- templates
|           `-- screen.sass
`-- tmp
    `-- hassle
        `-- css
            `-- screen.css

Include this in your views with:

<link href="/css/screen.css" media="screen" rel="stylesheet" type="text/css" />


Here’s how to integrate it with your favorite web framework:


For Rails: script/plugin install git:// Done. Once you’re in production mode, Hassle will kick in and prepare your SASS for all to enjoy.


Here’s a sample that’s up and running.

require 'sinatra'
require 'hassle'
require 'haml'

get '/' do
  haml <<EOF
    %link{:rel => 'stylesheet', :href => "stylesheets/application.css"}
    %h1 Hassle!

use Hassle
run Sinatra::Application

And its wonderful SASS file:

$ cat public/stylesheets/sass/application.sass 
  font-size: 11em
  color: purple


Found some problems? Post ’em in Issues.


Hassle uses the MIT license. Please check the LICENSE file for more details.