Class: Sass::Tree::ImportNode
- Defined in:
- lib/sass/tree/import_node.rb
Overview
A static node that wraps the Sass::Tree for an @import
ed file.
It doesn't have a functional purpose other than to add the @import
ed file
to the backtrace if an error occurs.
Instance Attribute Summary collapse
-
#imported_filename ⇒ String
readonly
The name of the imported file as it appears in the Sass document.
Attributes inherited from RootNode
Attributes inherited from Node
#children, #filename, #has_children, #line, #options
Instance Method Summary collapse
- #_cssize(*args) protected
-
#_perform(environment)
protected
Returns a static DirectiveNode if this is importing a CSS file, or parses and includes the imported Sass file.
- #cssize(*args)
-
#full_filename ⇒ String
Returns the resolved name of the imported file, as returned by Files#find_file_to_import.
-
#initialize(imported_filename) ⇒ ImportNode
constructor
A new instance of ImportNode.
- #invisible? ⇒ Boolean
-
#perform!(environment)
protected
Parses the imported file and runs the dynamic Sass for it.
- #to_sass(tabs = 0, opts = {})
- #to_scss(tabs = 0, opts = {})
Methods inherited from RootNode
#_to_s, #invalid_child?, #perform, #render, #to_s, #to_src
Methods inherited from Node
#<<, #==, #_to_s, #balance, #check_child!, #children_to_src, #cssize!, #dasherize, #do_extend, #each, #invalid_child?, #perform, #perform_children, #run_interp, #selector_to_sass, #selector_to_scss, #selector_to_src, #semi, #style, #to_s, #to_src
Constructor Details
#initialize(imported_filename) ⇒ ImportNode
Returns a new instance of ImportNode.
13 14 15 16 |
# File 'lib/sass/tree/import_node.rb', line 13
def initialize(imported_filename)
@imported_filename = imported_filename
super(nil)
end
|
Instance Attribute Details
#imported_filename ⇒ String (readonly)
The name of the imported file as it appears in the Sass document.
10 11 12 |
# File 'lib/sass/tree/import_node.rb', line 10
def imported_filename
@imported_filename
end
|
Instance Method Details
#_cssize(*args) (protected)
49 50 51 52 53 54 55 |
# File 'lib/sass/tree/import_node.rb', line 49
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.
62 63 64 65 |
# File 'lib/sass/tree/import_node.rb', line 62
def _perform(environment)
return DirectiveNode.new("@import url(#{full_filename})") if full_filename =~ /\.css$/
super
end
|
#cssize(*args)
42 43 44 |
# File 'lib/sass/tree/import_node.rb', line 42
def cssize(*args)
super.first
end
|
#full_filename ⇒ String
Returns the resolved name of the imported file, as returned by Files#find_file_to_import.
27 28 29 |
# File 'lib/sass/tree/import_node.rb', line 27
def full_filename
@full_filename ||= import
end
|
#invisible? ⇒ Boolean
18 |
# File 'lib/sass/tree/import_node.rb', line 18
def invisible?; to_s.empty?; end
|
#perform!(environment) (protected)
Parses the imported file and runs the dynamic Sass for it.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/sass/tree/import_node.rb', line 71
def perform!(environment)
environment.push_frame(:filename => @filename, :line => @line)
options = @options.dup
options.delete(:syntax)
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
ensure
environment.pop_frame
end
|
#to_sass(tabs = 0, opts = {})
32 33 34 |
# File 'lib/sass/tree/import_node.rb', line 32
def to_sass(tabs = 0, opts = {})
"#{' ' * tabs}@import #{@imported_filename}\n"
end
|
#to_scss(tabs = 0, opts = {})
37 38 39 |
# File 'lib/sass/tree/import_node.rb', line 37
def to_scss(tabs = 0, opts = {})
"#{' ' * tabs}@import \"#{@imported_filename}\";\n"
end
|