Tale\Jade\Parser\Node::find PHP Method

find() public method

Plus all it's children-children recursively and returns a generator providing them This is used to collect all blocks, imports and mixins and handle them in a special way If you need a normal array, use ->findArray() instead instead
public find ( string $type ) : Generator
$type string the node type to search for
return Generator a generator of the found children
    public function find($type)
    {
        foreach ($this->children as $node) {
            if ($node->type === $type) {
                (yield $node);
            }
            foreach ($node->find($type) as $subNode) {
                (yield $subNode);
            }
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Collects all imports and handles them via ->handleImport.
  *
  * @param Node $node the root Node to search imports in
  *
  * @return $this
  * @throws Exception when the allowImports-options is set to false
  */
 protected function handleImports(Node $node)
 {
     foreach ($node->find('import') as $importNode) {
         if (!$this->options['allowImports']) {
             $this->throwException('Imports are not allowed in this compiler instance', $node);
         }
         $this->handleImport($importNode);
     }
     return $this;
 }
All Usage Examples Of Tale\Jade\Parser\Node::find