Skip to content

Instantly share code, notes, and snippets.

@avand
Created September 15, 2010 23:59
Show Gist options
  • Save avand/581728 to your computer and use it in GitHub Desktop.
Save avand/581728 to your computer and use it in GitHub Desktop.
<%= stylesheet_link_tag stylesheets_path(:package => :desktop) %>
class AssetsApp < ActionController::Metal
include ActionController::Rendering
def stylesheets
@output = ''
Dir.glob("#{Rails.root}/app/stylesheets/#{params[:package]}/**/*.css*") do |filename|
sass_options = { :syntax => :scss }
sass_options[:style] = :compressed unless Rails.env.development?
@output += Sass::Engine.new(File.open(filename, 'r').read, sass_options).render
end
response.headers['Cache-Control'] = "public, max-age=#{1.year.seconds.to_i}" unless Rails.env.development?
response.content_type = 'text/css'
render :text => @output
end
end
gem 'haml', '3.0.18'
Sqoot::Application.routes.draw do |map|
match "/stylesheets/:package.css" => AssetsApp.action(:stylesheets), :as => 'stylesheets'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment