Class: Sass::Tree::ImportNode

Inherits:
RootNode 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 RootNode

#template

Attributes inherited from Node

#children, #filename, #line, #options

Instance Method Summary collapse

Methods inherited from RootNode

#_to_s, #cssize, #cssize!, #perform, #to_s

Methods inherited from Node

#<<, #==, #_to_s, #balance, #cssize, #cssize!, #interpolate, #invalid_child?, #last, #perform, #perform_children, #render, #style, #to_s, #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(nil)
end

Instance Method Details

#_cssize(*args) (protected)

See Also:



18
19
20
21
22
23
24
# File 'lib/sass/tree/import_node.rb', line 18

def _cssize(*args)
  super.children
rescue Sass::SyntaxError => e
  e.modify_backtrace(:filename => children.first.filename)
  e.add_backtrace(:filename => @filename, :line => @line)
  raise e
end

#_perform(environment) (protected)

Returns a static DirectiveNode if this is importing a CSS file, or parses and includes the imported Sass file.

Parameters:

  • environment (Sass::Environment)

    The lexical environment containing variable and mixin values



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

def _perform(environment)
  full_filename = import
  return DirectiveNode.new("@import url(#{full_filename})") if full_filename =~ /\.css$/

  node = dup
  node.perform!(environment, full_filename)
  node
end

#invisible?Boolean

Returns:

  • (Boolean)


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

def invisible?; to_s.empty?; end

#perform!(environment, full_filename) (protected)

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

Parameters:

  • environment (Sass::Environment)

    The lexical environment containing variable and mixin values

  • full_filename (String)

    The full path to the Sass file to import



45
46
47
48
49
50
51
52
53
54
# File 'lib/sass/tree/import_node.rb', line 45

def perform!(environment, full_filename)
  root = Sass::Files.tree_for(full_filename, @options)
  @template = root.template
  self.children = root.children
  self.children = perform_children(environment)
rescue Sass::SyntaxError => e
  e.modify_backtrace(:filename => full_filename)
  e.add_backtrace(:filename => @filename, :line => @line)
  raise e
end