Class: Sass::Tree::ImportNode
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
- - (String) imported_filename readonly The name of the imported file as it appears in the Sass document.
Instance Method Summary
- - _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)
- - (String) full_filename Returns the resolved name of the imported file, as returned by Sass::Files#find_file_to_import.
- - (ImportNode) initialize(imported_filename) constructor A new instance of ImportNode.
- - (Boolean) invisible?
- - 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
- (ImportNode) initialize(imported_filename)
A new instance of ImportNode
13 14 15 16 |
# File '/var/www/haml-pages/.haml/lib/sass/tree/import_node.rb', line 13
def initialize(imported_filename)
@imported_filename = imported_filename
super(nil)
end
|
Instance Attribute Details
- (String) imported_filename (readonly)
The name of the imported file as it appears in the Sass document.
10 11 12 |
# File '/var/www/haml-pages/.haml/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 '/var/www/haml-pages/.haml/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 '/var/www/haml-pages/.haml/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 '/var/www/haml-pages/.haml/lib/sass/tree/import_node.rb', line 42
def cssize(*args)
super.first
end
|
- (String) full_filename
Returns the resolved name of the imported file, as returned by Sass::Files#find_file_to_import.
27 28 29 |
# File '/var/www/haml-pages/.haml/lib/sass/tree/import_node.rb', line 27
def full_filename
@full_filename ||= import
end
|
- (Boolean) invisible?
18 |
# File '/var/www/haml-pages/.haml/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 '/var/www/haml-pages/.haml/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 '/var/www/haml-pages/.haml/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 '/var/www/haml-pages/.haml/lib/sass/tree/import_node.rb', line 37
def to_scss(tabs = 0, opts = {})
"#{' ' * tabs}@import \"#{@imported_filename}\";\n"
end
|