Skip to content

Commit 91f7509

Browse files
author
Rafael Mendonça França
committed
Merge pull request #292 from simplybusiness/fix_importer
Allow Importer to be serialized
2 parents 29505a2 + 4f33b1f commit 91f7509

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

lib/sass/rails/importer.rb

+4-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def find(name, options)
2828
private
2929
def glob_imports(base, glob, options)
3030
contents = ""
31-
each_globbed_file(base, glob) do |filename|
31+
context = options[:sprockets][:context]
32+
each_globbed_file(base, glob, context) do |filename|
3233
next if filename == options[:filename]
3334
contents << "@import #{filename.inspect};\n"
3435
end
@@ -39,7 +40,7 @@ def glob_imports(base, glob, options)
3940
))
4041
end
4142

42-
def each_globbed_file(base, glob)
43+
def each_globbed_file(base, glob, context)
4344
raise ArgumentError unless glob == "*" || glob == "**/*"
4445

4546
exts = extensions.keys.map { |ext| Regexp.escape(".#{ext}") }.join("|")
@@ -85,7 +86,7 @@ def find(*args)
8586
def process_erb_engine(engine)
8687
if engine && syntax = erb_extensions[engine.options[:syntax]]
8788
template = Tilt::ERBTemplate.new(engine.options[:filename])
88-
contents = template.render(context, {})
89+
contents = template.render(engine.options[:sprockets][:context], {})
8990

9091
Sass::Engine.new(contents, engine.options.merge(:syntax => syntax))
9192
else
@@ -136,13 +137,6 @@ def deprecate_extra_css_extension(engine)
136137
include ERB
137138
include Globbing
138139

139-
attr_reader :context
140-
141-
def initialize(context, *args)
142-
@context = context
143-
super(*args)
144-
end
145-
146140
# Allow .css files to be @import'd
147141
def extensions
148142
{ 'css' => :scss }.merge(super)

lib/sass/rails/template.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def evaluate(context, locals, &block)
3333
:line => line,
3434
:syntax => syntax,
3535
:cache_store => cache_store,
36-
:importer => importer_class.new(context, context.pathname.to_s),
37-
:load_paths => context.environment.paths.map { |path| importer_class.new(context, path.to_s) },
36+
:importer => importer_class.new(context.pathname.to_s),
37+
:load_paths => context.environment.paths.map { |path| importer_class.new(path.to_s) },
3838
:sprockets => {
3939
:context => context,
4040
:environment => context.environment

0 commit comments

Comments
 (0)