{"record":{"id":"b481caebc714fd42","repo":"octobercms/october","slug":"invalid-syntax-in-the-content-tag-line-s","errorCode":null,"errorMessage":"Invalid syntax in the content tag. Line %s","messagePattern":"Invalid syntax in the content tag\\. Line (.+?)","errorType":"exception","errorClass":"Twig\\Error\\SyntaxError","httpStatus":null,"severity":"error","filePath":"modules/cms/twig/tokenparser/ContentTokenParser.php","lineNumber":48,"sourceCode":"\n        $nodes = [];\n        $paramNames = [];\n\n        // Parse content name (first argument)\n        $nodes['__content_name'] = $this->parser->parseExpression();\n\n        // Parse optional parameters\n        while (!$stream->test(TwigToken::BLOCK_END_TYPE)) {\n            $current = $stream->next();\n\n            if ($current->test(TwigToken::NAME_TYPE)) {\n                $paramName = $current->getValue();\n                $stream->expect(TwigToken::OPERATOR_TYPE, '=');\n                $nodes[$paramName] = $this->parser->parseExpression();\n                $paramNames[] = $paramName;\n            }\n            else {\n                throw new TwigErrorSyntax(\n                    sprintf('Invalid syntax in the content tag. Line %s', $lineno),\n                    $stream->getCurrent()->getLine(),\n                    $stream->getSourceContext()\n                );\n            }\n        }\n\n        $stream->expect(TwigToken::BLOCK_END_TYPE);\n\n        // Pass individual nodes instead of wrapping in a 'nodes' array\n        return new ContentNode($nodes, $paramNames, $lineno, $this->getTag());\n    }\n\n    /**\n     * Returns the tag name associated with this token parser.\n     * @return string\n     */\n    public function getTag()","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/twig/tokenparser/ContentTokenParser.php#L30-L66","documentation":"The {% content %} tag parses a content-block name expression (e.g. {% content 'intro.htm' %}) followed by optional name = expression parameters. Any token in the parameter loop that is not a NAME beginning an assignment - a string, number, comma, or operator - throws this SyntaxError with the tag's starting line.","triggerScenarios":"Writing {% content 'intro.htm' 'raw' %} (bare extra value), {% content 'intro.htm' name 'John' %} (missing =), or {% content 'intro.md' name='John', year=2013 x %} where a stray token follows - the loop's else branch throws. Note the documented syntax separates params with commas, but each param itself must be name = value.","commonSituations":"Passing extra positional values to content blocks; missing the equals sign; a trailing comma after the last parameter.","solutions":["Use only name = expression pairs after the content name: {% content 'intro.htm' name='John' year=2013 %}.","Remove stray commas, strings, or leftover tokens in the tag.","Check the reported line in the page/partials source - the message echoes the tag's start line."],"exampleFix":"{# before: bare second value and missing = #}\n{% content 'intro.htm' 'raw' %}\n\n{# after: named parameters only #}\n{% content 'intro.htm' name='John' year=2013 %}","handlingStrategy":"validation","validationCode":"$env = app('twig.environment');\ntry {\n    $env->parse($env->tokenize(new \\Twig\\Source($templateBody, $fileName)));\n} catch (\\Twig\\Error\\SyntaxError $e) {\n    // reject invalid {% content %} syntax at lint time\n}","typeGuard":null,"tryCatchPattern":"try {\n    $env->parse($env->tokenize(new \\Twig\\Source($body, $name)));\n} catch (\\Twig\\Error\\SyntaxError $e) {\n    // 'Invalid syntax in the content tag' - fix params to name = value pairs\n}","preventionTips":["Follow the documented form: {% content 'file.htm' name='x' year=2013 %}.","Never pass bare positional values after the content name.","Lint templates in CI."],"tags":["twig","syntax-error","content-tag","template"],"backgroundTag":"template-syntax-error","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}