Permalink
Browse files

Grep visitor for finding nodes in the AST.

  • Loading branch information...
1 parent 10645f5 commit 25bc305a40ecd9ffcbda8942a9bd786b9f5904ad @chriseppstein chriseppstein committed Sep 12, 2011
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/sass/tree/visitors/grep.rb
@@ -0,0 +1,13 @@
+# A visitor for copying the full structure of a Sass tree.
+class Sass::Tree::Visitors::Grep < Sass::Tree::Visitors::Base
+ protected
+
+ def visit(node, &block)
+ found = []
+ found << node if yield(node)
+ node.children.each do |child|
+ found += visit(child, &block)
+ end
+ found
+ end
+end

0 comments on commit 25bc305

Please sign in to comment.