Skip to content

Commit

Permalink
Sprockets 4 Compatibility
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
schneems committed Jun 23, 2016
1 parent 1a58a4e commit b0bb332
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ script: "bundle exec rake test"
gemfile:
- gemfiles/sprockets_2_12.gemfile
- gemfiles/sprockets_3_0.gemfile
- gemfiles/sprockets_4_0.gemfile
- gemfiles/sprockets-rails_3_0.gemfile
- gemfiles/rails_4_2.gemfile
- gemfiles/rails_4_1.gemfile
Expand Down
6 changes: 6 additions & 0 deletions gemfiles/sprockets_4_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

gem "sprockets", "~> 4.0.x"

# Specify your gem's dependencies in sassc-rails.gemspec
gemspec path: "../"
9 changes: 7 additions & 2 deletions lib/sassc/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ class Railtie < ::Rails::Railtie
self.sass_config = app.config.sass
end

env.register_engine '.sass', SassC::Rails::SassTemplate
env.register_engine '.scss', SassC::Rails::ScssTemplate
if env.respond_to?(:register_transformer)
env.register_transformer 'text/sass', 'text/css', SassC::Rails::SassTemplate.new #->() { puts "yoyoyoy" }
env.register_transformer 'text/scss', 'text/css', SassC::Rails::ScssTemplate.new #->() { puts "yoyoyoy" }
else
env.register_engine '.sass', SassC::Rails::SassTemplate
env.register_engine '.scss', SassC::Rails::ScssTemplate
end
end
end

Expand Down
11 changes: 9 additions & 2 deletions lib/sassc/rails/template.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
require "sprockets/version"
require "sprockets/sass_template"

begin
require 'sprockets/sass_processor'
rescue LoadError
require "sprockets/sass_template"
end

require "sprockets/utils"

module SassC::Rails
class SassTemplate < Sprockets::SassTemplate

class SassTemplate < defined?(Sprockets::SassProcessor) ? Sprockets::SassProcessor : Sprockets::SassTemplate
module Sprockets3
def call(input)
context = input[:environment].context_class.new(input)
Expand Down

0 comments on commit b0bb332

Please sign in to comment.