octobercms/october · error · TwigErrorSyntax
When using put with a block, you cannot have multiple…
Error message
When using put with a block, you cannot have multiple targets.
What it means
Twig syntax error raised in PutTokenParser::parse: capture mode ({% put name %}...{% endput %}) was used with multiple comma-separated targets. Only a single placeholder name may be captured in block mode; multiple targets are only valid with direct assignment.
Solutions
- Use exactly one variable name in the block form of put
- Use the assignment form ({% put a, b = ... %}) for multiple targets
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/cms/twig/tokenparser/PutTokenParser.php:54 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/c19f99f30fa92c08.
Report an issue: GitHub.
Appendix: source
Thrown at modules/cms/twig/tokenparser/PutTokenParser.php:54
if ($stream->nextIf(TwigToken::OPERATOR_TYPE, '=')) {
// Direct assignment mode
$values = $this->parseMultitargetExpression();
$stream->expect(TwigToken::BLOCK_END_TYPE);
if (count($names) !== count($values)) {
throw new TwigErrorSyntax(
'When using put, you must have the same number of variables and assignments.',
$stream->getCurrent()->getLine(),
$stream->getSourceContext()
);
}
}
else {
// Capture mode
$capture = true;
if (count($names) > 1) {
throw new TwigErrorSyntax(
'When using put with a block, you cannot have multiple targets.',
$stream->getCurrent()->getLine(),
$stream->getSourceContext()
);
}
while (!$stream->test(TwigToken::BLOCK_END_TYPE)) {
$current = $stream->next();
if ($current->test(TwigToken::NAME_TYPE)) {
$options[] = strtolower(trim($current->getValue()));
}
else {
throw new TwigErrorSyntax(
sprintf('Invalid syntax in the put tag. Line %s', $lineno),
$stream->getCurrent()->getLine(),
$stream->getSourceContext()
);
}View on GitHub (pinned to b608633a7e)