class Sass::Tree::Visitors::Base
@abstract
for dealing with the return value of ‘@else` nodes.
In particular, there is no built-in scaffolding
special care must be taken to ensure that it is properly handled.
Note: due to the unusual nature of {Sass::Tree::IfNode},
They may `yield` to visit the child nodes of the current node.
These methods take the node in question as argument.
(e.g. `visit_rule` for {RuleNode} or `visit_for` for {ForNode}).
then implement `visit_*` methods for each node they care about
Visitors should extend this class,
The abstract base class for Sass visitors.
def self.node_name(node)
-
(String)
- The name.
Parameters:
-
node
(Tree::Node
) -- The node.
def self.node_name(node) Sass::Util.deprecated(self, "Call node.class.node_name instead.") node.class.node_name end
def self.visit(root)
-
(Object)
- The return value of \{#visit} for the root node.
Parameters:
-
root
(Tree::Node
) -- The root node of the Sass tree.
def self.visit(root) new.send(:visit, root) end
def visit(node)
-
(Object)
- The return value of the `visit_*` method for this node.
Parameters:
-
node
(Tree::Node
) -- The node to visit.
def visit(node) if respond_to?(node.class.visit_method, true) send(node.class.visit_method, node) {visit_children(node)} else visit_children(node) end end
def visit_children(parent)
-
(Array
- The return values of the `visit_*` methods for the children.
Parameters:
-
parent
(Tree::Node
) -- The parent node of the children to visit.
def visit_children(parent) parent.children.map {|c| visit(c)} end
def visit_if(node)
`yield`s, then runs the visitor on the `@else` clause if the node has one.
def visit_if(node) yield visit(node.else) if node.else node end