Goetas\Twital\Attribute\ElseAttribute::visit PHP Method

visit() public method

public visit ( DOMAttr $att, Compiler $context )
$att DOMAttr
$context Goetas\Twital\Compiler
    public function visit(\DOMAttr $att, Compiler $context)
    {
        $node = $att->ownerElement;
        if (!($prev = IfAttribute::findPrevElement($node))) {
            throw new Exception("The attribute 'elseif' must be the very next sibling of an 'if' of 'elseif' attribute");
        }
        $pi = $context->createControlNode("else");
        $node->parentNode->insertBefore($pi, $node);
        $pi = $context->createControlNode("endif");
        $node->parentNode->insertBefore($pi, $node->nextSibling);
        $node->removeAttributeNode($att);
    }
ElseAttribute