Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Added support for SCSS (the new sass) #5

Open
wants to merge 3 commits into from

1 participant

crystalneth
This page is out of date. Refresh to see the latest.
4  lib/asset_resource/framework/rails_view_helpers.rb
... ...
@@ -1,11 +1,11 @@
1 1
 module AssetResource
2 2
   module Helpers
3 3
     def asset_resource_stylesheets(resource_name = "stylesheets")
4  
-      "<link rel='stylesheet' href='/assets/#{resource_name}.css' />".html_safe
  4
+      "<link rel='stylesheet' href='/assets/#{resource_name}.css?#{Time.now.to_i}' />".html_safe
5 5
     end
6 6
 
7 7
     def asset_resource_javascripts(resource_name = "javascripts")
8  
-      "<script type='text/javascript' src='/assets/#{resource_name}.js'></script>".html_safe
  8
+      "<script type='text/javascript' src='/assets/#{resource_name}.js?#{Time.now.to_i}'></script>".html_safe
9 9
     end
10 10
   end
11 11
 end
17  lib/asset_resource/middleware.rb
@@ -37,6 +37,15 @@ def initialize(app, options={})
37 37
         raise "Tried to translate a sass file but could not find the library.\nTry adding this to your Gemfile:\n  gem \"haml\""
38 38
       end
39 39
     end
  40
+    
  41
+    translator :scss do |filename|
  42
+      begin
  43
+        require 'sass'
  44
+        Sass::Engine.new(File.read(filename), :syntax => :scss, :load_paths => [File.dirname(filename)]).render
  45
+      rescue LoadError
  46
+        raise "Tried to translate a sass file but could not find the library.\nTry adding this to your Gemfile:\n  gem \"haml\""
  47
+      end
  48
+    end
40 49
   end
41 50
 
42 51
   def call(env)
@@ -59,8 +68,12 @@ def base_path
59 68
   end
60 69
 
61 70
   def files_for(type)
62  
-    Dir.glob(File.expand_path(File.join(base_path, type, "**", "*"))).select do |file|
63  
-      File.exist?(file) && File.basename(file)[0..0] != "_"
  71
+    if filenames = options[:handlers][:files]
  72
+      filenames.map{|filename| File.join(base_path, type, filename)}.select{|file| File.exists?(file)}
  73
+    else
  74
+      Dir.glob(File.expand_path(File.join(base_path, type, "**", "*"))).select do |file|
  75
+        File.exist?(file) && File.basename(file)[0..0] != "_"
  76
+      end
64 77
     end
65 78
   end
66 79
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.