From: Fabien Potencier Date: Sat, 27 Nov 2010 09:10:04 +0000 (+0100) Subject: changed trans tag to accept any variable for the plural count X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=bea562a2464cb68b1f20247b80fc93c6a3d74d01;p=web%2Fkonrad%2Ftwig.git changed trans tag to accept any variable for the plural count --- 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); }