Skip to content

Commit

Permalink
added an exception when misusing macro calls (refs twigphp#922)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Dec 7, 2012
1 parent 496537a commit 3ca17ac
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Twig/ExpressionParser.php
Expand Up @@ -393,6 +393,10 @@ public function parseSubscriptExpression($node)
}

if ($node instanceof Twig_Node_Expression_Name && null !== $alias = $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
if (!$arg instanceof Twig_Node_Expression_Constant) {
throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s")', $node->getAttribute('name')), $token->getLine(), $this->parser->getFilename());
}

$node = new Twig_Node_Expression_MethodCall($node, 'get'.$arg->getAttribute('value'), $arguments, $lineno);
$node->setAttribute('safe', true);

Expand Down

0 comments on commit 3ca17ac

Please sign in to comment.