Class Sass::Tree::ImportNode
In: lib/sass/tree/import_node.rb
Parent: RootNode
Haml::Util Engine Color SyntaxError UnitConversionError StandardError AbstractSequence CommaSequence Sequence SimpleSequence Simple Parent Universal Class SelectorPseudoClass Id Pseudo Attribute Interpolation Element Node Operation Literal UnaryOperation StringInterpolation Funcall Interpolation Variable Lexer CssLexer Number Bool String Parser Parser CssParser EvaluationContext SassParser StaticParser CssParser Node DebugNode IfNode CommentNode ForNode PropNode MixinNode DirectiveNode VariableNode RootNode ExtendNode WarnNode WhileNode RuleNode MixinDefNode Enumerable ImportNode Merb::BootLoader MerbBootLoader Repl CSS Environment Rack StalenessChecker lib/sass/repl.rb lib/sass/css.rb lib/sass/environment.rb lib/sass/error.rb lib/sass/engine.rb lib/sass/selector/simple_sequence.rb lib/sass/selector/abstract_sequence.rb lib/sass/selector/sequence.rb lib/sass/selector/comma_sequence.rb lib/sass/selector/simple.rb lib/sass/selector.rb Selector lib/sass/script/css_parser.rb lib/sass/script/lexer.rb lib/sass/script/color.rb lib/sass/script/string.rb lib/sass/script/unary_operation.rb lib/sass/script/variable.rb lib/sass/script/funcall.rb lib/sass/script/string_interpolation.rb lib/sass/script/operation.rb lib/sass/script/bool.rb lib/sass/script/parser.rb lib/sass/script/node.rb lib/sass/script/literal.rb lib/sass/script/interpolation.rb lib/sass/script/css_lexer.rb lib/sass/script/number.rb lib/sass/script/functions.rb Functions Script lib/sass/scss/sass_parser.rb lib/sass/scss/static_parser.rb lib/sass/scss/parser.rb lib/sass/scss/css_parser.rb ScriptLexer ScriptParser RX SCSS Files Callbacks lib/sass/tree/while_node.rb lib/sass/tree/if_node.rb lib/sass/tree/mixin_def_node.rb lib/sass/tree/debug_node.rb lib/sass/tree/root_node.rb lib/sass/tree/for_node.rb lib/sass/tree/import_node.rb lib/sass/tree/prop_node.rb lib/sass/tree/node.rb lib/sass/tree/comment_node.rb lib/sass/tree/extend_node.rb lib/sass/tree/mixin_node.rb lib/sass/tree/warn_node.rb lib/sass/tree/directive_node.rb lib/sass/tree/rule_node.rb lib/sass/tree/variable_node.rb Tree lib/sass/plugin/rack.rb lib/sass/plugin/staleness_checker.rb lib/sass/plugin/merb.rb Plugin Sass dot/m_63_0.png

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.

Methods

Attributes

imported_filename  [R]  The name of the imported file as it appears in the Sass document.

@return [String]

Public Class methods

@param imported_filename [String] The name of the imported file

[Source]

    # File lib/sass/tree/import_node.rb, line 13
13:       def initialize(imported_filename)
14:         @imported_filename = imported_filename
15:         super(nil)
16:       end

Public Instance methods

@see Node#cssize

[Source]

    # File lib/sass/tree/import_node.rb, line 42
42:       def cssize(*args)
43:         super.first
44:       end

Returns the resolved name of the imported file, as returned by \{Sass::Files#find_file_to_import}.

@return [String] The filename of the imported file.

  This is an absolute path if the file is a `".sass"` or `".scss"` file.

@raise [Sass::SyntaxError] if `filename` ends in `".sass"` or `".scss"`

  and no corresponding Sass file could be found.

[Source]

    # File lib/sass/tree/import_node.rb, line 27
27:       def full_filename
28:         @full_filename ||= import
29:       end

[Source]

    # File lib/sass/tree/import_node.rb, line 18
18:       def invisible?; to_s.empty?; end

@see Node#to_sass

[Source]

    # File lib/sass/tree/import_node.rb, line 32
32:       def to_sass(tabs = 0, opts = {})
33:         "#{'  ' * tabs}@import #{@imported_filename}\n"
34:       end

@see Node#to_scss

[Source]

    # File lib/sass/tree/import_node.rb, line 37
37:       def to_scss(tabs = 0, opts = {})
38:         "#{'  ' * tabs}@import \"#{@imported_filename}\";\n"
39:       end

Protected Instance methods

@see Node#_cssize

[Source]

    # File lib/sass/tree/import_node.rb, line 49
49:       def _cssize(*args)
50:         super.children
51:       rescue Sass::SyntaxError => e
52:         e.modify_backtrace(:filename => children.first.filename)
53:         e.add_backtrace(:filename => @filename, :line => @line)
54:         raise e
55:       end

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

@param environment [Sass::Environment] The lexical environment containing

  variable and mixin values

[Source]

    # File lib/sass/tree/import_node.rb, line 62
62:       def _perform(environment)
63:         return DirectiveNode.new("@import url(#{full_filename})") if full_filename =~ /\.css$/
64:         super
65:       end

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

@param environment [Sass::Environment] The lexical environment containing

  variable and mixin values

[Source]

    # File lib/sass/tree/import_node.rb, line 71
71:       def perform!(environment)
72:         environment.push_frame(:filename => @filename, :line => @line)
73:         options = @options.dup
74:         options.delete(:syntax)
75:         root = Sass::Files.tree_for(full_filename, options)
76:         @template = root.template
77:         self.children = root.children
78:         self.children = perform_children(environment)
79:       rescue Sass::SyntaxError => e
80:         e.modify_backtrace(:filename => full_filename)
81:         e.add_backtrace(:filename => @filename, :line => @line)
82:         raise e
83:       ensure
84:         environment.pop_frame
85:       end

Private Instance methods

[Source]

    # File lib/sass/tree/import_node.rb, line 95
95:       def import
96:         Sass::Files.find_file_to_import(@imported_filename, import_paths)
97:       rescue Exception => e
98:         raise SyntaxError.new(e.message, :line => self.line, :filename => @filename)
99:       end

[Source]

    # File lib/sass/tree/import_node.rb, line 89
89:       def import_paths
90:         paths = (@options[:load_paths] || []).dup
91:         paths.unshift(File.dirname(@options[:filename])) if @options[:filename]
92:         paths
93:       end

[Validate]