octobercms/october · error · Twig\Error\SyntaxError
Invalid syntax in the framework tag. Line %s
Error message
Invalid syntax in the framework tag. Line %s
What it means
The {% framework %} tag accepts only bare word options (NAME tokens), lowercased into the framework node's options - e.g. {% framework extras %}. Any token that is not a NAME - a quoted string, number, equals sign, or operator - throws this SyntaxError with the tag's starting line. Unlike the component/content tags there are no assignments at all.
Source
Thrown at modules/cms/twig/tokenparser/FrameworkTokenParser.php:38
class FrameworkTokenParser extends TwigTokenParser
{
/**
* Parses a token and returns a node.
* @return FrameworkNode
*/
public function parse(TwigToken $token)
{
$lineno = $token->getLine();
$stream = $this->parser->getStream();
$options = [];
while (!$stream->test(TwigToken::BLOCK_END_TYPE)) {
if ($stream->test(TwigToken::NAME_TYPE)) {
$options[] = strtolower(trim($stream->next()->getValue()));
}
else {
throw new TwigErrorSyntax(
sprintf('Invalid syntax in the framework tag. Line %s', $lineno),
$stream->getCurrent()->getLine(),
$stream->getSourceContext()
);
}
}
$stream->expect(TwigToken::BLOCK_END_TYPE);
return new FrameworkNode($options, $lineno, $this->getTag());
}
/**
* Returns the tag name associated with this token parser.
* @return string
*/
public function getTag()
{View on GitHub (pinned to b608633a7e)
Solutions
- Use bare words without quotes or equals signs: {% framework extras %}.
- Pass only documented options (e.g. extras); anything else belongs in theme configuration, not this tag.
- Re-save the template - compilation fails until the tag is fixed.
Example fix
{# before: quoted option - not a NAME token #}
{% framework 'extras' %}
{# after #}
{% framework extras %} Defensive patterns
Strategy: validation
Validate before calling
$env = app('twig.environment');
try {
$env->parse($env->tokenize(new \Twig\Source($templateBody, $fileName)));
} catch (\Twig\Error\SyntaxError $e) {
// reject invalid {% framework %} syntax at lint time
} Try / catch
try {
$env->parse($env->tokenize(new \Twig\Source($body, $name)));
} catch (\Twig\Error\SyntaxError $e) {
// 'Invalid syntax in the framework tag' - use bare word options only
} Prevention
- Write options as bare words: {% framework extras %} - no quotes, no equals.
- Do not invent key=value flags for this tag.
- Lint templates in CI before release.
When it happens
Trigger: Writing {% framework 'extras' %} (quoted string instead of the bare word), {% framework extras=true %} (attempted assignment), or {% framework 1 %} - each produces a non-NAME token in the loop.
Common situations: Quoting the option out of string-literal habit; copying the syntax from the {% scripts %} or {% styles %} variants that behave differently; adding unsupported key=value flags.
Related errors
- Unknown "%s" configuration.
- The "%s" modifier takes exactly one argument (0 given).
- The "%s" modifier takes exactly one argument (2 given).
- Invalid syntax in the component tag. Line %s
- Invalid syntax in the content tag. Line %s
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/1646028eb62dad42.
Report an issue: GitHub.