Class: Sass::Tree::ImportNode

Inherits:
Node show all
Defined in:
lib/sass/tree/import_node.rb

Overview

A static node that wraps the Sass::Tree for an @imported file. It doesn't have a functional purpose other than to add the @imported file to the backtrace if an error occurs.

Instance Attribute Summary

Attributes inherited from Node

#children, #filename, #line, #options

Instance Method Summary collapse

Methods inherited from Node

#<<, #==, #_perform, #balance, #interpolate, #invalid_child?, #last, #perform, #perform_children, #render, #style, #to_sass

Constructor Details

#initialize(imported_filename) ⇒ ImportNode

Returns a new instance of ImportNode.

Parameters:

  • imported_filename (String)

    The name of the imported file



8
9
10
11
# File 'lib/sass/tree/import_node.rb', line 8

def initialize(imported_filename)
  @imported_filename = imported_filename
  super()
end

Instance Method Details

#invisible?Boolean

Returns:

  • (Boolean)


23
# File 'lib/sass/tree/import_node.rb', line 23

def invisible?; to_s.empty?; end

#perform!(environment) ⇒ Object (protected)

Parses the imported file and runs the dynamic Sass for it.

Parameters:

  • environment (Sass::Environment)

    The lexical environment containing variable and mixin values



32
33
34
35
36
37
38
39
# File 'lib/sass/tree/import_node.rb', line 32

def perform!(environment)
  return unless full_filename = import
  self.children = Sass::Files.tree_for(full_filename, @options).children
  self.children = perform_children(environment)
rescue Sass::SyntaxError => e
  e.add_backtrace_entry(@filename)
  raise e
end

#to_s(*args) ⇒ Object

Computes the CSS for the imported file.

Parameters:

  • args (Array)

    Ignored



16
17
18
19
20
21
# File 'lib/sass/tree/import_node.rb', line 16

def to_s(*args)
  @to_s ||= (style == :compressed ? super().strip : super())
rescue Sass::SyntaxError => e
  e.add_backtrace_entry(@filename)
  raise e
end