Run javascript and css templates through erb.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Chuusha (pronounced chew-sha) is a Rack adapter that treats your css and javascript files as erb templates. It also provides a basic facility for sharing constants between all your templates and the rest of your Rack stack. It will continually evaluate templates in dev mode, while caching the rendered template in production. It plays nicely with Rails's asset caching.

Installation and Usage

First install the gem:

$ gem install chuusha

Next, require the gem and tell your rack application to use chuusha. You will need to point it at the directory containing your public assets.

# in ./
require 'chuusha'

use Chuusha::Rack, File.dirname(__FILE__) + '/public'
run"/" => YOUR_RAILS_APP::Application)

Now place a css erb template somewhere in '/public/stylesheets'

# in ./public/stylesheets/application.css.erb

<% highlight_color = "#fc6666" %>

p.highlight {
  color: <%= highlight_color %>;

div.highlight {
  border: 1px solid <%= highlight_color %>;

Common Variables

Occasionally, you'll want to share variables amongst many templates. To do so, pass a hash of variables to Chuusha like so:

use Chuusha::Rack,
    File.dirname(__FILE__) + '/public',
    { "variables" => { "highlight_color" => "#fc6666" }}

This would add highlight_color as a variable in both your css and js erb templates.

On Heroku

Since Heroku won't allow you write to the file system, you'll have to tell Chuusha to write to /tmp. This is done by passing an output directory to Chuusha like so:

use Chuusha::Rack,
    File.dirname(__FILE__) + '/public',
    File.dirname(__FILE__) + '/tmp'


Chuusha is still pretty young and probably has bugs. Feel free to email me (Trotter Cashion) at if you find anything. Alternately, you can tweet me at @cashion, as I often respond more quickly to public humiliation :-).


Thanks to Mat Schaffer for the name.

Thanks to Barry O'Gorman for fixing Heroku support.