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

        $subject = $node->subject;

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

        $hasChildren = count($node->children) > 0;
        $isDoWhile = $node->prev() && $node->prev()->type === 'do';

        if (!$hasChildren && !$isDoWhile)
            $this->throwException(
                'A while-loop without children you loop through is not valid if'
                .' there\'s no do-statement before it.',
                $node
            );
        else if ($isDoWhile && $hasChildren)
            $this->throwException(
                'In a do-while statement the while-part shouldn\'t have any children. Put the children in the `do`-part',
                $node
            );

        $phtml = $this->createCode("while ({$subject})".($hasChildren ? ' {' : ''), $isDoWhile ? ' ' : '<?php ').$this->newLine();

        if ($hasChildren) {

            $phtml .= $this->compileChildren($node->children).$this->newLine();
            $phtml .= $this->indent().$this->createCode('}').$this->newLine();
        }

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

        $subject = $node->subject;

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

        $hasChildren = count($node->children) > 0;
        $isDoWhile = $node->prev() && $node->prev()->type === 'do';

        if (!$hasChildren && !$isDoWhile)
            $this->throwException(
                'A while-loop without children you loop through is not valid if'
                .' there\'s no do-statement before it.',
                $node
            );
        else if ($isDoWhile && $hasChildren)
            $this->throwException(
                'In a do-while statement the while-part shouldn\'t have any children. Put the children in the `do`-part',
                $node
            );

        $phtml = $this->createCode("while ({$subject})".($hasChildren ? ' {' : ''), $isDoWhile ? ' ' : '<?php ').$this->newLine();

        if ($hasChildren) {

            $phtml .= $this->compileChildren($node->children).$this->newLine();
            $phtml .= $this->indent().$this->createCode('}').$this->newLine();
        }

        return $phtml;
    }
protected function compileWhile ( Node $ node ) { $ subject = $ node -> subject ; if ( $ this -> isVariable ( $ subject ) ) $ subject = "isset({$subject}) ? {$subject} : null" ; $ hasChildren = count ( $ node -> children ) > 0 ; $ isDoWhile = $ node -> prev ( ) && $ node -> prev ( ) -> type === 'do' ; if ( ! $ hasChildren && ! $ isDoWhile ) $ this -> throwException ( 'A while-loop without children you loop through is not valid if' . ' there\'s no do-statement before it.' , $ node ) ; else if ( $ isDoWhile && $ hasChildren ) $ this -> throwException ( 'In a do-while statement the while-part shouldn\'t have any children. Put the children in the `do`-part' , $ node ) ; $ phtml = $ this -> createCode ( "while ({$subject})" . ( $ hasChildren ? ' {' : '' ) , $ isDoWhile ? ' ' : '<?php ' ) . $ this -> newLine ( ) ; if ( $ hasChildren ) { $ phtml .= $ this -> compileChildren ( $ node -> children ) . $ this -> newLine ( ) ; $ phtml .= $ this -> indent ( ) . $ this -> createCode ( '}' ) . $ this -> newLine ( ) ; } return $ phtml ; }
Compiles a while-loop into PHTML.

Notice that if it has no children, we assume it's a do/while loop
and don't print brackets

@param Node $node the while-node to compile

@return string The compiled PHTML
Compiles a while - loop into PHTML .