Compiler.php
protected function compileEach(Node $node)
    {

        $subject = $node->subject;

        if ($this->isVariable($subject))
            $subject = "isset({$subject}) ? {$subject} : []";

        $as = "\${$node->itemName}";

        if ($node->keyName)
            $as = "\${$node->keyName} => ".$as;

        $var = '$__iterator'.($this->iteratorId++);
        $phtml = $this->createCode("$var = {$subject};").$this->newLine();
        $phtml .= $this->indent().$this->createCode("foreach ($var as $as) {").$this->newLine();
        $phtml .= $this->compileChildren($node->children).$this->newLine();
        $phtml .= $this->indent().$this->createCode('}').$this->newLine();
        $phtml .= $this->indent().$this->createCode("unset($var);");

        return $phtml;
    }
protected function compileEach(Node $node)
    {

        $subject = $node->subject;

        if ($this->isVariable($subject))
            $subject = "isset({$subject}) ? {$subject} : []";

        $as = "\${$node->itemName}";

        if ($node->keyName)
            $as = "\${$node->keyName} => ".$as;

        $var = '$__iterator'.($this->iteratorId++);
        $phtml = $this->createCode("$var = {$subject};").$this->newLine();
        $phtml .= $this->indent().$this->createCode("foreach ($var as $as) {").$this->newLine();
        $phtml .= $this->compileChildren($node->children).$this->newLine();
        $phtml .= $this->indent().$this->createCode('}').$this->newLine();
        $phtml .= $this->indent().$this->createCode("unset($var);");

        return $phtml;
    }
protected function compileEach ( Node $ node ) { $ subject = $ node -> subject ; if ( $ this -> isVariable ( $ subject ) ) $ subject = "isset({$subject}) ? {$subject} : []" ; $ as = "\${$node->itemName}" ; if ( $ node -> keyName ) $ as = "\${$node->keyName} => " . $ as ; $ var = '$__iterator' . ( $ this -> iteratorId ++ ) ; $ phtml = $ this -> createCode ( "$var = {$subject};" ) . $ this -> newLine ( ) ; $ phtml .= $ this -> indent ( ) . $ this -> createCode ( "foreach ($var as $as) {" ) . $ this -> newLine ( ) ; $ phtml .= $ this -> compileChildren ( $ node -> children ) . $ this -> newLine ( ) ; $ phtml .= $ this -> indent ( ) . $ this -> createCode ( '}' ) . $ this -> newLine ( ) ; $ phtml .= $ this -> indent ( ) . $ this -> createCode ( "unset($var);" ) ; return $ phtml ; }
Compiles a each-instruction into a foreach-loop PHTML block.

the $ in the variables names are optional

@param Node $node the each-node to compile

@return string The compiled PHTML
Compiles a each - instruction into a foreach - loop PHTML block .