Skip to content

Commit

Permalink
[TwigBundle] fixed trans tag
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 29, 2010
1 parent 8ad2fd2 commit 7b9a523
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Symfony/Bundle/TwigBundle/TokenParser/TransTokenParser.php
Expand Up @@ -34,17 +34,29 @@ public function parse(\Twig_Token $token)

$domain = new \Twig_Node_Expression_Constant('messages', $lineno);
if (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
$body = null;
if (!$stream->test('from')) {
// {% trans "message" %}
$body = $this->parser->getExpressionParser()->parseExpression();
}

if ($stream->test('from')) {
// {% trans "message" from "messages" %}
$stream->next();
$domain = $this->parser->getExpressionParser()->parseExpression();

// {% trans from "messages" %}message{% endtrans %}
if (null === $body) {
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);
}
} else {
throw new \Twig_SyntaxError(sprintf('Unexpected token. Twig was looking for the "from" keyword line %s)', $lineno), -1);
}
} else {
// {% trans %}message{% endtrans %}
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
$body = $this->parser->subparse(array($this, 'decideTransFork'));
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);
}

$stream->expect(\Twig_Token::BLOCK_END_TYPE);
Expand Down

0 comments on commit 7b9a523

Please sign in to comment.