From bea562a2464cb68b1f20247b80fc93c6a3d74d01 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 27 Nov 2010 10:10:04 +0100 Subject: [PATCH] changed trans tag to accept any variable for the plural count --- CHANGELOG | 1 + lib/Twig/TokenParser/Trans.php | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ceb28cb..771243a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ Backward incompatibilities: * removed support for {{ 1 < i < 3 }} (use {{ i > 1 and i < 3 }} instead) Changes: + * changed trans tag to accept any variable for the plural count * fixed sandbox mode (__toString() method check was not enforced if called implicitly from complex statements) * added the ** (power) operator * changed the algorithm used for parsing expressions diff --git a/lib/Twig/TokenParser/Trans.php b/lib/Twig/TokenParser/Trans.php index d542417..2c11d07 100644 --- a/lib/Twig/TokenParser/Trans.php +++ b/lib/Twig/TokenParser/Trans.php @@ -30,7 +30,7 @@ class Twig_TokenParser_Trans extends Twig_TokenParser $stream->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideForFork')); if ('plural' === $stream->next()->getValue()) { - $count = new Twig_Node_Expression_Name($stream->expect(Twig_Token::NAME_TYPE)->getValue(), $lineno); + $count = $this->parser->getExpressionParser()->parseExpression(); $stream->expect(Twig_Token::BLOCK_END_TYPE); $plural = $this->parser->subparse(array($this, 'decideForEnd'), true); } -- 1.7.2.5