{"record":{"id":"fdce796b1e3495c8","repo":"getgrav/grav","slug":"unexpected-end-of-template-twig-was-looking-for-t","errorCode":null,"errorMessage":"Unexpected end of template. Twig was looking for the following tags \"case\", \"default\", or \"endswitch\" to close the \"switch\" block started at line %d)","messagePattern":"Unexpected end of template\\. Twig was looking for the following tags \"case\", \"default\", or \"endswitch\" to close the \"switch\" block started at line (.+?)\\)","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php","lineNumber":96,"sourceCode":"                    $stream->expect(Token::BLOCK_END_TYPE);\n                    $body = $this->parser->subparse($this->decideIfFork(...));\n                    $cases[] = new class([\n                        'values' => new Nodes($values),\n                        'body' => $body\n                    ]) extends Node {};\n                    break;\n\n                case 'default':\n                    $stream->expect(Token::BLOCK_END_TYPE);\n                    $default = $this->parser->subparse($this->decideIfEnd(...));\n                    break;\n\n                case 'endswitch':\n                    $end = true;\n                    break;\n\n                default:\n                    throw new SyntaxError(sprintf('Unexpected end of template. Twig was looking for the following tags \"case\", \"default\", or \"endswitch\" to close the \"switch\" block started at line %d)', $lineno), -1);\n            }\n        }\n\n        $stream->expect(Token::BLOCK_END_TYPE);\n\n        return new TwigNodeSwitch($name, new Nodes($cases), $default, $lineno, $this->getTag());\n    }\n\n    /**\n     * Decide if current token marks switch logic.\n     *\n     * @param Token $token\n     * @return bool\n     */\n    public function decideIfFork(Token $token): bool\n    {\n        return $token->test(['case', 'default', 'endswitch']);\n    }","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php#L78-L114","documentation":"Error \"Unexpected end of template. Twig was looking for the following tags \"case\", \"default\", or \"endswitch\" to close the \"switch\" block started at line %d)\" thrown in getgrav/grav.","triggerScenarios":"Thrown at system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php:96 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}