-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[close #381] Avoid Sprockets deprecations
- Use both `register_engine` and `register_transformer` in railtie.rb. - In the test postprocessor use an object that responds to `call` and `new.render`.
- Loading branch information
Showing
5 changed files
with
47 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source "https://rubygems.org" | ||
|
||
# Specify your gem"s dependencies in sass-rails.gemspec | ||
gemspec path: ".." | ||
|
||
gem "rails" | ||
gem "sprockets", "~> 4.x" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 23 additions & 3 deletions
26
test/fixtures/scss_project/config/initializers/postprocessor.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
Rails.application.config.assets.configure do |env| | ||
env.register_postprocessor 'text/css', :postprocessor do |context, css| | ||
css.gsub /@import/, 'fail engine' | ||
|
||
class SassRailsTestPostProcessor | ||
def initialize(filename, &block) | ||
@filename = filename | ||
@source = block.call | ||
end | ||
|
||
def render(context) | ||
self.class.run(@source) | ||
end | ||
|
||
def self.run(source) | ||
source.gsub /@import/, 'fail engine' | ||
end | ||
|
||
def self.call(input) | ||
source = input[:data] | ||
result = run(source) | ||
{ data: result } | ||
end | ||
end | ||
|
||
Rails.application.config.assets.configure do |env| | ||
env.register_postprocessor 'text/css', SassRailsTestPostProcessor | ||
end |