Class | Sass::Tree::Node |
In: |
lib/sass/tree/node.rb
|
Parent: | Object |
The abstract superclass of all parse-tree nodes.
children | [RW] |
The child nodes of this node.
@return [Array<Tree::Node>] |
filename | [W] |
The name of the document on which this node appeared.
@return [String] |
has_children | [RW] |
Whether or not this node has child nodes. This may be true even when
\{children} is empty, in which case this node has an empty block (e.g.
`{}`).
@return [Boolean] |
line | [RW] |
The line of the document on which this node appeared.
@return [Fixnum] |
options | [R] |
The options hash for the node. See {file:SASS_REFERENCE.md#sass_options the
Sass options documentation}.
@return [{Symbol => Object}] |
Appends a child to the node.
@param child [Tree::Node, Array<Tree::Node>] The child node or nodes @raise [Sass::SyntaxError] if `child` is invalid @see invalid_child?
Compares this node and another object (only other {Tree::Node}s will be equal). This does a structural comparison; if the contents of the nodes and all the child nodes are equivalent, then the nodes are as well.
Only static nodes need to override this.
@param other [Object] The object to compare with @return [Boolean] Whether or not this node and the other object
are the same
@see Sass::Tree
Raises an error if the given child node is invalid.
@param child [Tree::Node] The child node @raise [Sass::SyntaxError] if `child` is invalid @see invalid_child?
Converts a static Sass tree (e.g. the output of \{perform}) into a static CSS tree.
\{cssize} shouldn‘t be overridden directly; instead, override \{_cssize} or \{cssize!}.
@param extends [Haml::Util::SubsetMap{Selector::Simple => Selector::Sequence}]
The extensions defined for this tree
@param parent [Node, nil] The parent node of this node.
This should only be non-nil if the parent is the same class as this node
@return [Tree::Node] The resulting tree of static nodes @raise [Sass::SyntaxError] if some element of the tree is invalid @see Sass::Tree
Converts a static CSS tree (e.g. the output of \{cssize}) into another static CSS tree, with the given extensions applied to all relevant {RuleNode}s.
@todo Link this to the reference documentation on `@extend`
when such a thing exists.
@param extends [Haml::Util::SubsetMap{Selector::Simple => Selector::Sequence}]
The extensions to perform on this tree
@return [Tree::Node] The resulting tree of static CSS nodes. @raise [Sass::SyntaxError] Only if there‘s a programmer error
and this is not a static CSS tree
True if \{to_s} will return `nil`; that is, if the node shouldn‘t be rendered. Should only be called in a static tree.
@return [Boolean]
Sets the options hash for the node and all its children.
@param options [{Symbol => Object}] The options @see options
Converts a dynamic tree into a static Sass tree. That is, runs the dynamic Sass code: mixins, variables, control directives, and so forth. This doesn‘t modify this node or any of its children.
\{perform} shouldn‘t be overridden directly; instead, override \{_perform} or \{perform!}.
@param environment [Sass::Environment] The lexical environment containing
variable and mixin values
@return [Tree::Node] The resulting tree of static nodes @raise [Sass::SyntaxError] if some element of the tree is invalid @see Sass::Tree
Computes the CSS corresponding to this static CSS tree.
\{to_s} shouldn‘t be overridden directly; instead, override \{_to_s}. Only static-node subclasses need to implement \{to_s}.
This may return `nil`, but it will only do so if \{invisible?} is true.
@param args [Array] Passed on to \{_to_s} @return [String, nil] The resulting CSS @see Sass::Tree
Converts this static Sass node into a static CSS node, returning the new node. This doesn‘t modify this node or any of its children.
@param extends [Haml::Util::SubsetMap{Selector::Simple => Selector::Sequence}]
The extensions defined for this tree
@param parent [Node, nil] The parent node of this node.
This should only be non-nil if the parent is the same class as this node
@return [Tree::Node, Array<Tree::Node>] The resulting static CSS nodes @raise [Sass::SyntaxError] if some element of the tree is invalid @see cssize @see Sass::Tree
Runs any dynamic Sass code in this particular node. This doesn‘t modify this node or any of its children.
@param environment [Sass::Environment] The lexical environment containing
variable and mixin values
@return [Tree::Node, Array<Tree::Node>] The resulting static nodes @see perform @see Sass::Tree
Computes the CSS corresponding to this particular Sass node.
This method should never raise {Sass::SyntaxError}s. Such errors will not be properly annotated with Sass backtrace information. All error conditions should be checked in earlier transformations, such as \{cssize} and \{perform}.
@param args [Array] ignored @return [String, nil] The resulting CSS @see to_s @see Sass::Tree
Converts the children of this node to a Sass or SCSS string. This will return the trailing newline for the previous line, including brackets if this is SCSS.
@param tabs [Fixnum] The amount of tabulation to use for the Sass code @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize}) @param fmt [Symbol] `:sass` or `:scss` @return [String] The Sass or SCSS code corresponding to the children
Destructively converts this static Sass node into a static CSS node. This does modify this node, but will be run non-destructively by \{_cssize\}.
@param extends [Haml::Util::SubsetMap{Selector::Simple => Selector::Sequence}]
The extensions defined for this tree
@param parent [Node, nil] The parent node of this node.
This should only be non-nil if the parent is the same class as this node
@see cssize
Returns an error message if the given child node is invalid, and false otherwise.
By default, all child nodes except those only allowed under specific nodes ({Tree::MixinDefNode}, {Tree::ImportNode}, {Tree::ExtendNode}) are valid. This is expected to be overriden by subclasses for which some children are invalid.
@param child [Tree::Node] A potential child node @return [Boolean, String] Whether or not the child node is valid,
as well as the error message to display if it is invalid
Destructively runs dynamic Sass code in this particular node. This does modify this node, but will be run non-destructively by \{_perform\}.
@param environment [Sass::Environment] The lexical environment containing
variable and mixin values
@see perform
Non-destructively runs \{perform} on all children of the current node.
@param environment [Sass::Environment] The lexical environment containing
variable and mixin values
@return [Array<Tree::Node>] The resulting static nodes
Replaces SassScript in a chunk of text with the resulting value.
@param text [Array<String, Sass::Script::Node>] The text to interpolate @param environment [Sass::Environment] The lexical environment containing
variable and mixin values
@return [String] The interpolated text
Converts a selector to a Sass string.
@param sel [Array<String, Sass::Script::Node>] The selector to convert @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize}) @return [String] The Sass code corresponding to the selector
Converts a selector to a SCSS string.
@param sel [Array<String, Sass::Script::Node>] The selector to convert @param tabs [Fixnum] The indentation of the selector @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize}) @return [String] The SCSS code corresponding to the selector
Converts a selector to a Sass or SCSS string.
@param sel [Array<String, Sass::Script::Node>] The selector to convert @param tabs [Fixnum] The indentation of the selector @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize}) @param fmt [Symbol] `:sass` or `:scss` @return [String] The Sass or SCSS code corresponding to the selector
Converts a node to Sass or SCSS code that will generate it.
This method is called by the default \{to_sass} and \{to_scss} methods, so that the same code can be used for both with minor variations.
@param tabs [Fixnum] The amount of tabulation to use for the SCSS code @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize}) @param fmt [Symbol] `:sass` or `:scss` @return [String] The Sass or SCSS code corresponding to the node