Class Sass::Script::Node
In: lib/sass/script/node.rb
Parent: Object
Haml::Util Engine Color SyntaxError UnitConversionError StandardError AbstractSequence CommaSequence Sequence SimpleSequence Simple Parent Universal Class Negation Id Pseudo Attribute Interpolation Element Node Operation Literal UnaryOperation StringInterpolation Funcall Variable Interpolation Lexer CssLexer Number String Bool Parser Parser CssParser EvaluationContext StaticParser SassParser CssParser Node DebugNode IfNode CommentNode ForNode PropNode MixinNode DirectiveNode VariableNode RootNode WarnNode ExtendNode RuleNode MixinDefNode WhileNode 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 ScriptParser ScriptLexer 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_61_0.png

The abstract superclass for SassScript parse tree nodes.

Use \{perform} to evaluate a parse tree.

Methods

_perform   children   context=   dasherize   new   options=   perform   to_sass  

Attributes

context  [R]  The context in which this node was parsed, which determines how some operations are performed.

Can be `:equals`, which means it‘s part of a `$var = val` or `prop = val` assignment, or `:default`, which means it‘s anywhere else (including `$var: val` and `prop: val` assignments, `#{}`-interpolations, and other script contexts such as `@if` conditions).

@return [Symbol]

line  [RW]  The line of the document on which this node appeared.

@return [Fixnum]

options  [R]  The options hash for this node.

@return [{Symbol => Object}]

Public Class methods

Creates a new script node.

[Source]

    # File lib/sass/script/node.rb, line 49
49:     def initialize
50:       @context = :default
51:     end

Public Instance methods

Returns all child nodes of this node.

@return [Array<Node>]

[Source]

    # File lib/sass/script/node.rb, line 70
70:     def children
71:       raise NotImplementedError.new("All subclasses of Sass::Script::Node must override #children.")
72:     end

Sets the context for this node, as well as for all child nodes.

@param context [Symbol] @see context

[Source]

    # File lib/sass/script/node.rb, line 43
43:     def context=(context)
44:       @context = context
45:       children.each {|c| c.context = context}
46:     end

Sets the options hash for this node, as well as for all child nodes. See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.

@param options [{Symbol => Object}] The options

[Source]

    # File lib/sass/script/node.rb, line 33
33:     def options=(options)
34:       @options = options
35:       children.each {|c| c.options = options}
36:     end

Evaluates the node.

\{perform} shouldn‘t be overridden directly; instead, override \{_perform}.

@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [Literal] The SassScript object that is the value of the SassScript

[Source]

    # File lib/sass/script/node.rb, line 60
60:     def perform(environment)
61:       _perform(environment)
62:     rescue Sass::SyntaxError => e
63:       e.modify_backtrace(:line => line)
64:       raise e
65:     end

Returns the text of this SassScript expression.

@return [String]

[Source]

    # File lib/sass/script/node.rb, line 77
77:     def to_sass(opts = {})
78:       raise NotImplementedError.new("All subclasses of Sass::Script::Node must override #to_sass.")
79:     end

Protected Instance methods

Evaluates this node.

@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [Literal] The SassScript object that is the value of the SassScript @see perform

[Source]

    # File lib/sass/script/node.rb, line 97
97:     def _perform(environment)
98:       raise NotImplementedError.new("All subclasses of Sass::Script::Node must override #_perform.")
99:     end

Converts underscores to dashes if the :dasherize option is set.

[Source]

    # File lib/sass/script/node.rb, line 84
84:     def dasherize(s, opts)
85:       if opts[:dasherize]
86:         s.gsub(/_/,'-')
87:       else
88:         s
89:       end
90:     end

[Validate]