Skip to content

Sinatra Integration

Dorian edited this page Mar 3, 2016 · 2 revisions

A minimal Sinatra app preconfigured for Compass:

require 'sinatra'
require 'haml'
require 'sass'
require 'compass'

configure do
  Compass.configuration do |config|
    config.project_path = File.dirname(__FILE__)
    config.sass_dir = 'views'
  end

  set :haml, format: :html5
  set :sass, Compass.sass_engine_options
  set :scss, Compass.sass_engine_options
end

get '/sass.css' do
  sass :sass_file
end

get '/scss.css' do
  scss :scss_file
end

If you keep your stylesheets in "views/stylesheets/" directory instead of just "views/", remember to update sass_dir configuration accordingly.

Check out this sample compass-sinatra project to get up and running in no time!

Sinatra Projects:

  • Sinatra Bootstrap - a base Sinatra project with support for Haml, Sass, Compass, jQuery and more.
Clone this wiki locally