Skip to content

Instantly share code, notes, and snippets.

@spraints
Created July 15, 2009 15:42
Show Gist options
  • Save spraints/147798 to your computer and use it in GitHub Desktop.
Save spraints/147798 to your computer and use it in GitHub Desktop.
# This is a really simple Sinatra extension to make it easy to use compass.
# Its configuration isn't all that great, but its usage is:
#
# require 'sinatra/compass'
# get "/main.css" do
# compass :main
# end
require 'sinatra/base'
module Sinatra
module CompassTemplates
module Helpers
def compass(template, options={}, locals={})
options = options.merge(:sass => Compass.sass_engine_options.merge(options[:sass]))
sass template, options, locals
end
end
def self.registered(app)
app.helpers CompassTemplates::Helpers
Compass.configuration do |config|
# I'm not sure if the app configuration is done at this point..
# Is there a way to watch for future changes to app.views and update
# compass when that happens? Does it even matter (i.e. can I drop this
# config block)?
config.project_path = app.root
config.sass_dir = app.views
end
end
end
register CompassTemplates
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment