Latte\Macros\CoreMacros::macroElse PHP Method

macroElse() public method

{else}
public macroElse ( MacroNode $node, PhpWriter $writer )
$node Latte\MacroNode
$writer Latte\PhpWriter
    public function macroElse(MacroNode $node, PhpWriter $writer)
    {
        if ($node->modifiers) {
            throw new CompileException('Modifiers are not allowed in ' . $node->getNotation());
        } elseif ($node->args) {
            $hint = Helpers::startsWith($node->args, 'if') ? ', did you mean {elseif}?' : '';
            throw new CompileException('Arguments are not allowed in ' . $node->getNotation() . $hint);
        }
        $ifNode = $node->parentNode;
        if ($ifNode && $ifNode->name === 'if' && $ifNode->data->capture) {
            if (isset($ifNode->data->else)) {
                throw new CompileException('Macro {if} supports only one {else}.');
            }
            $ifNode->data->else = TRUE;
            return 'ob_start(function () {})';
        }
        return '} else {';
    }