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

        $type = $node->conditionType;
        $subject = $node->subject;

        if ($subject === 'block')
            $subject = '$__block';

        if ($this->isVariable($subject))
            $subject = "isset($subject) ? $subject : false";

        if ($type === 'unless') {

            $type = 'if';
            $subject = "!($subject)";
        }

        $isPrevConditional = $node->prev() && $node->prev()->type === 'conditional' && $type !== 'if';
        $isNextConditional = $node->next()
            && $node->next()->type === 'conditional'
            && $node->next()->conditionType !== 'if'
            && $node->next()->conditionType !== 'unless';
        $prefix = $isPrevConditional ? '' : '<?php ';
        $suffix = $isNextConditional ? '' : '?>';
        $phtml = $type === 'else'
            ? $this->createCode(' else {', $prefix)
            : $this->createCode("$type ($subject) {", $prefix);
        $phtml .= $this->compileChildren($node->children);
        $phtml .= $this->newLine().$this->indent().$this->createCode("}", '<?php ', $suffix);

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

        $type = $node->conditionType;
        $subject = $node->subject;

        if ($subject === 'block')
            $subject = '$__block';

        if ($this->isVariable($subject))
            $subject = "isset($subject) ? $subject : false";

        if ($type === 'unless') {

            $type = 'if';
            $subject = "!($subject)";
        }

        $isPrevConditional = $node->prev() && $node->prev()->type === 'conditional' && $type !== 'if';
        $isNextConditional = $node->next()
            && $node->next()->type === 'conditional'
            && $node->next()->conditionType !== 'if'
            && $node->next()->conditionType !== 'unless';
        $prefix = $isPrevConditional ? '' : '<?php ';
        $suffix = $isNextConditional ? '' : '?>';
        $phtml = $type === 'else'
            ? $this->createCode(' else {', $prefix)
            : $this->createCode("$type ($subject) {", $prefix);
        $phtml .= $this->compileChildren($node->children);
        $phtml .= $this->newLine().$this->indent().$this->createCode("}", '<?php ', $suffix);

        return $phtml;
    }
protected function compileConditional ( Node $ node ) { $ type = $ node -> conditionType ; $ subject = $ node -> subject ; if ( $ subject === 'block' ) $ subject = '$__block' ; if ( $ this -> isVariable ( $ subject ) ) $ subject = "isset($subject) ? $subject : false" ; if ( $ type === 'unless' ) { $ type = 'if' ; $ subject = "!($subject)" ; } $ isPrevConditional = $ node -> prev ( ) && $ node -> prev ( ) -> type === 'conditional' && $ type !== 'if' ; $ isNextConditional = $ node -> next ( ) && $ node -> next ( ) -> type === 'conditional' && $ node -> next ( ) -> conditionType !== 'if' && $ node -> next ( ) -> conditionType !== 'unless' ; $ prefix = $ isPrevConditional ? '' : '<?php ' ; $ suffix = $ isNextConditional ? '' : '?>' ; $ phtml = $ type === 'else' ? $ this -> createCode ( ' else {' , $ prefix ) : $ this -> createCode ( "$type ($subject) {" , $ prefix ) ; $ phtml .= $ this -> compileChildren ( $ node -> children ) ; $ phtml .= $ this -> newLine ( ) . $ this -> indent ( ) . $ this -> createCode ( "}" , '<?php ' , $ suffix ) ; return $ phtml ; }
Compiles a conditional, either if, elseif, else if or else into PHTML.

@param Node $node the conditional node to compile

@return string The compiled PHTML
Compiles a conditional either if elseif else if or else into PHTML .