Skip to content

Commit 155f3ff

Browse files
committed
Merge pull request #340 from Andreis13/no-tilt
Use Sprockets processors instead of Tilt for ERB processing.
2 parents 6594807 + 5e09809 commit 155f3ff

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/sass/rails/importer.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require 'active_support/deprecation/reporting'
22
require 'sprockets/sass_importer'
3-
require 'tilt'
3+
require 'sprockets/file_reader'
4+
require 'sprockets/erb_processor'
5+
require 'sprockets/processor_utils'
46

57
module Sass
68
module Rails
@@ -85,10 +87,20 @@ def find(*args)
8587
private
8688
def process_erb_engine(engine)
8789
if engine && engine.options[:sprockets] && syntax = erb_extensions[engine.options[:syntax]]
88-
template = Tilt::ERBTemplate.new(engine.options[:filename])
89-
contents = template.render(engine.options[:sprockets][:context], {})
90+
context = engine.options[:sprockets][:context]
9091

91-
Sass::Engine.new(contents, engine.options.merge(:syntax => syntax))
92+
input = {
93+
filename: engine.options[:filename],
94+
environment: context.environment,
95+
content_type: "text/#{syntax}",
96+
metadata: {}
97+
}
98+
99+
processors = [Sprockets::ERBProcessor, Sprockets::FileReader]
100+
101+
result = Sprockets::ProcessorUtils.call_processors(processors, input)
102+
103+
Sass::Engine.new(result[:data], engine.options.merge(:syntax => syntax))
92104
else
93105
engine
94106
end

sass-rails.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
1717
s.add_dependency 'sass', '~> 3.3'
1818
s.add_dependency 'sprockets-rails', '>= 3.0', '< 4.0'
1919
s.add_dependency 'sprockets', '>= 4.0'
20-
s.add_dependency 'tilt', '>= 1.1', '< 3'
2120

2221
s.add_development_dependency 'sqlite3'
2322

0 commit comments

Comments
 (0)