Method: Less::Node::Element#each

Defined in:
lib/less/engine/nodes/element.rb

#each(path = [], &blk) ⇒ Object Also known as: traverse



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/less/engine/nodes/element.rb', line 121

def each path = [], &blk
#
# Traverse the whole tree, returning each leaf or branch (recursive)
#
###
  #   Aside from the key & value, we yield the full path of the leaf,  
  #   aswell as the branch which contains it (self).
  #   Note that in :branch mode, we only return 'twigs', branches which contain leaves.
  #
  elements.each do |element|                            
    path << element                         
    yield element, path if element.leaf?                
    element.each path, &blk                                        
    path.pop                    
  end
  self
end