Skip to content

Commit 775fbbd

Browse files
committed
Sprockets 4 Compatibility
I'm able to get a really simple test app working with this gem with these changes, but so far haven't gotten the tests to pass.
1 parent 1a58a4e commit 775fbbd

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ script: "bundle exec rake test"
77
gemfile:
88
- gemfiles/sprockets_2_12.gemfile
99
- gemfiles/sprockets_3_0.gemfile
10+
- gemfiles/sprockets_4_0.gemfile
1011
- gemfiles/sprockets-rails_3_0.gemfile
1112
- gemfiles/rails_4_2.gemfile
1213
- gemfiles/rails_4_1.gemfile

gemfiles/sprockets_4_0.gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
gem "sprockets", "~> 4.0.x"
4+
5+
# Specify your gem's dependencies in sassc-rails.gemspec
6+
gemspec path: "../"

lib/sassc/rails/railtie.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ class Railtie < ::Rails::Railtie
5050
self.sass_config = app.config.sass
5151
end
5252

53-
env.register_engine '.sass', SassC::Rails::SassTemplate
54-
env.register_engine '.scss', SassC::Rails::ScssTemplate
53+
if env.respond_to?(:register_transformer)
54+
env.register_transformer 'text/sass', 'text/css', SassC::Rails::SassTemplate.new #->() { puts "yoyoyoy" }
55+
env.register_transformer 'text/scss', 'text/css', SassC::Rails::ScssTemplate.new #->() { puts "yoyoyoy" }
56+
else
57+
env.register_engine '.sass', SassC::Rails::SassTemplate
58+
env.register_engine '.scss', SassC::Rails::ScssTemplate
59+
end
5560
end
5661
end
5762

lib/sassc/rails/template.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
require "sprockets/version"
2-
require "sprockets/sass_template"
2+
3+
begin
4+
require 'sprockets/sass_processor'
5+
rescue LoadError
6+
require "sprockets/sass_template"
7+
end
8+
39
require "sprockets/utils"
410

511
module SassC::Rails
6-
class SassTemplate < Sprockets::SassTemplate
12+
13+
class SassTemplate < defined?(Sprockets::SassProcessor) ? Sprockets::SassProcessor : Sprockets::SassTemplate
714
module Sprockets3
815
def call(input)
916
context = input[:environment].context_class.new(input)

0 commit comments

Comments
 (0)