From e596d2136eb74bea7e640c750b45433bbcb07bcf Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 16 Jun 2010 20:04:39 +0200 Subject: [PATCH] fixed set tag when used with a capture (closes #70) --- CHANGELOG | 1 + lib/Twig/TokenParser/Set.php | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 36d12d2..296567a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ * 0.9.8 + * fixed set tag when used with a capture * fixed type hinting for Twig_Environment::addFilter() method * 0.9.7 (2010-06-12) diff --git a/lib/Twig/TokenParser/Set.php b/lib/Twig/TokenParser/Set.php index 25731c7..04bc178 100644 --- a/lib/Twig/TokenParser/Set.php +++ b/lib/Twig/TokenParser/Set.php @@ -29,6 +29,10 @@ class Twig_TokenParser_Set extends Twig_TokenParser list(, $values) = $this->parser->getExpressionParser()->parseMultitargetExpression(); $stream->expect(Twig_Token::BLOCK_END_TYPE); + + if (count($names) !== count($values)) { + throw new Twig_SyntaxError("When using set, you must have the same number of variables and assignements.", $lineno); + } } else { $capture = true; @@ -42,10 +46,6 @@ class Twig_TokenParser_Set extends Twig_TokenParser $stream->expect(Twig_Token::BLOCK_END_TYPE); } - if (count($names) !== count($values)) { - throw new Twig_SyntaxError("When using set, you must have the same number of variables and assignements.", $lineno); - } - return new Twig_Node_Set($capture, $names, $values, $lineno, $this->getTag()); } -- 1.7.2.5