Class: Less::Rails::ImportProcessor

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/less/rails/import_processor.rb

Constant Summary collapse

IMPORT_SCANNER =
/@import\s*['"]([^'"]+)['"]\s*;/.freeze

Instance Method Summary collapse

Instance Method Details

#depend_on(scope, data) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/less/rails/import_processor.rb', line 15

def depend_on(scope, data)
  import_paths = data.scan(IMPORT_SCANNER).flatten.compact.uniq
  import_paths.each do |path|
    pathname = begin
                 scope.resolve(path)
               rescue Sprockets::FileNotFound
                 nil
               end
    scope.depend_on(path) if pathname && pathname.to_s.ends_with?('.less')
    depend_on scope, File.read(pathname) if pathname
  end
  data
end

#evaluate(scope, locals, &block) ⇒ Object



10
11
12
13
# File 'lib/less/rails/import_processor.rb', line 10

def evaluate(scope, locals, &block)
  depend_on scope, data
  data
end

#prepareObject



7
8
# File 'lib/less/rails/import_processor.rb', line 7

def prepare
end