Created
January 28, 2009 03:44
-
-
Save mikedamage/53802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# = 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