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.
Constant Summary
Constants inherited from Node
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.
-
#css_import? ⇒ Boolean
Returns whether or not this import should emit a CSS @import declaration.
- #cssize(*args)
-
#imported_file ⇒ Sass::Engine
Returns the imported file.
-
#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
#<<, #==, #_around_dump, #_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)
57 58 59 60 61 62 63 |
# File 'lib/sass/tree/import_node.rb', line 57
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.
70 71 72 73 74 75 |
# File 'lib/sass/tree/import_node.rb', line 70
def _perform(environment)
if path = css_import?
return DirectiveNode.new("@import url(#{path})")
end
super
end
|
#css_import? ⇒ Boolean
Returns whether or not this import should emit a CSS @import declaration
46 47 48 49 50 51 52 |
# File 'lib/sass/tree/import_node.rb', line 46
def css_import?
if @imported_filename =~ /\.css$/
@imported_filename
elsif imported_file.is_a?(String) && imported_file =~ /\.css$/
imported_file
end
end
|
#cssize(*args)
39 40 41 |
# File 'lib/sass/tree/import_node.rb', line 39
def cssize(*args)
super.first
end
|
#imported_file ⇒ Sass::Engine
Returns the imported file.
24 25 26 |
# File 'lib/sass/tree/import_node.rb', line 24
def imported_file
@imported_file ||= 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.
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/sass/tree/import_node.rb', line 81
def perform!(environment)
environment.push_frame(:filename => @filename, :line => @line)
# TODO: re-enable caching
root = imported_file.to_tree
self.children = root.children
self.children = perform_children(environment)
rescue Sass::SyntaxError => e
e.modify_backtrace(:filename => imported_file.options[:filename])
e.add_backtrace(:filename => @filename, :line => @line)
raise e
ensure
environment.pop_frame
end
|
#to_sass(tabs = 0, opts = {})
29 30 31 |
# File 'lib/sass/tree/import_node.rb', line 29
def to_sass(tabs = 0, opts = {})
"#{' ' * tabs}@import #{@imported_filename}\n"
end
|
#to_scss(tabs = 0, opts = {})
34 35 36 |
# File 'lib/sass/tree/import_node.rb', line 34
def to_scss(tabs = 0, opts = {})
"#{' ' * tabs}@import \"#{@imported_filename}\";\n"
end
|