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

#perform, #to_s

Methods inherited from Node

#<<, #==, #_perform, #balance, #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

#_to_s(*args) ⇒ Object (protected)

Computes the CSS for the imported file.

Parameters:

  • args (Array)

    Ignored



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

def _to_s(*args)
  @to_s ||= (style == :compressed ? super.strip : super)
rescue Sass::SyntaxError => e
  e.modify_backtrace(:filename => children.first.filename)
  e.add_backtrace(:filename => @filename, :line => @line)
  raise e
end

#invisible?Boolean

Returns:

  • (Boolean)


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

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



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/sass/tree/import_node.rb', line 33

def perform!(environment)
  return unless full_filename = import
  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