]> git.openstreetmap.org Git - rails.git/blobdiff - config/initializers/r2.rb
Update bundle
[rails.git] / config / initializers / r2.rb
index 70676ca7e0e128cc371c1021f91c9dd71ebe5462..4f951b30ce70b9dd8b49b0a2a083d31c47ebe405 100644 (file)
@@ -1,21 +1,16 @@
-class R2Template < Tilt::Template
-  self.default_mime_type = 'text/css'
+require "r2"
 
-  def self.engine_initialized?
-    defined? ::R2
-  end
-
-  def initialize_engine
-    require_template_library "r2"
-  end
-
-  def prepare
-    @output = R2.r2(data)
-  end
-  
-  def evaluate(scope, locals, &block)
-    @output
+class R2ScssProcessor < SassC::Rails::ScssTemplate
+  def self.call(input)
+    output = super(input)
+    data = R2.r2(output[:data])
+    output.delete(:map)
+    output.merge(:data => data)
   end
 end
 
-Rails.application.assets.register_engine ".r2", R2Template
+Rails.application.config.assets.configure do |env|
+  env.register_mime_type "text/r2+scss", :extensions => [".r2.scss"]
+  env.register_transformer "text/r2+scss", "text/css", R2ScssProcessor
+  env.register_preprocessor "text/r2+scss", Sprockets::DirectiveProcessor.new(:comments => ["//", ["/*", "*/"]])
+end