Class: Less::Rails::ImportProcessor
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Less::Rails::ImportProcessor
- Defined in:
- lib/less/rails/import_processor.rb
Constant Summary collapse
- IMPORT_SCANNER =
/@import\s*['"]([^'"]+)['"]\s*;/.freeze
- PATHNAME_FINDER =
Proc.new { |scope, path| begin scope.resolve(path) rescue Sprockets::FileNotFound nil end }
Instance Method Summary collapse
- #depend_on(scope, data, base = File.dirname(scope.logical_path)) ⇒ Object
- #evaluate(scope, locals, &block) ⇒ Object
- #prepare ⇒ Object
Instance Method Details
#depend_on(scope, data, base = File.dirname(scope.logical_path)) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/less/rails/import_processor.rb', line 22 def depend_on(scope, data, base=File.dirname(scope.logical_path)) import_paths = data.scan(IMPORT_SCANNER).flatten.compact.uniq import_paths.each do |path| pathname = PATHNAME_FINDER.call(scope,path) || PATHNAME_FINDER.call(scope, File.join(base, path)) scope.depend_on(pathname) if pathname && pathname.to_s.ends_with?('.less') depend_on scope, File.read(pathname), File.dirname(path) if pathname end data end |
#evaluate(scope, locals, &block) ⇒ Object
17 18 19 20 |
# File 'lib/less/rails/import_processor.rb', line 17 def evaluate(scope, locals, &block) depend_on scope, data data end |
#prepare ⇒ Object
14 15 |
# File 'lib/less/rails/import_processor.rb', line 14 def prepare end |