Skip to content

Instantly share code, notes, and snippets.

@mikedamage
Created January 28, 2009 03:44
Show Gist options
  • Save mikedamage/53802 to your computer and use it in GitHub Desktop.
Save mikedamage/53802 to your computer and use it in GitHub Desktop.
# = Sinatra Action: Sass Stylesheet Compressor/Renderer
#
# == Summary
# Renders Sass stylesheets in the specified format.
# Valid formats are: extended, expanded, compact, compressed
get "/sass/:format/:file" do
content_type 'text/css', :charset => 'utf-8'
if params[:file] =~ /\.sass$/
@file = Pathname.new("./views/sass/" + params[:file])
else
@file = Pathname.new("./views/sass/" + (params[:file] + ".sass"))
end
if @file.exist?
@format = params[:format].intern
@sass = Sass::Engine.new(@file.read, {:style => @format})
@sass.render
else
raise not_found, "Sass stylesheet not found."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment