Skip to content

Instantly share code, notes, and snippets.

@GusGA
Forked from jharjono/sinatra_sass_coffee.rb
Last active August 29, 2015 14:08
Show Gist options
  • Save GusGA/de83fc120404cd8831fe to your computer and use it in GitHub Desktop.
Save GusGA/de83fc120404cd8831fe to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Libraries:::::::::::::::::::::::::::::::::::::::::::::::::::::::
require 'rubygems'
require 'sinatra/base'
require 'slim'
require 'sass'
require 'coffee-script'
# Application:::::::::::::::::::::::::::::::::::::::::::::::::::
class SassHandler < Sinatra::Base
set :views, File.dirname(__FILE__) + '/templates/sass'
get '/css/*.css' do
filename = params[:splat].first
sass filename.to_sym
end
end
class CoffeeHandler < Sinatra::Base
set :views, File.dirname(__FILE__) + '/templates/coffee'
get "/js/*.js" do
filename = params[:splat].first
coffee filename.to_sym
end
end
class MyApp < Sinatra::Base
use SassHandler
use CoffeeHandler
# Configuration:::::::::::::::::::::::::::::::::::::::::::::::
set :public, File.dirname(__FILE__) + '/public'
set :views, File.dirname(__FILE__) + '/templates'
# Route Handlers::::::::::::::::::::::::::::::::::::::::::::::
get '/' do
slim :index
end
end
if __FILE__ == $0
MyApp.run! :port => 4567
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment