mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 11:27:00 +00:00
fixed SimpleTokenParser accepts comma(",") in grammar
This commit is contained in:
committed by
Fabien Potencier
parent
839f16145e
commit
a115a0667d
@@ -108,7 +108,7 @@ abstract class Twig_SimpleTokenParser extends Twig_TokenParser
|
||||
}
|
||||
$grammar->addGrammar(new $class($match[1]));
|
||||
$cursor += strlen($match[0]);
|
||||
} elseif (preg_match('/(\w+)/A', $str, $match, null, $cursor)) {
|
||||
} elseif (preg_match('/(\w+|,)/A', $str, $match, null, $cursor)) {
|
||||
$grammar->addGrammar(new Twig_Grammar_Constant($match[1]));
|
||||
$cursor += strlen($match[0]);
|
||||
} elseif (preg_match('/\[/A', $str, $match, null, $cursor)) {
|
||||
|
||||
@@ -96,6 +96,17 @@ class Twig_Tests_SimpleTokenParserTest extends PHPUnit_Framework_TestCase
|
||||
)
|
||||
)
|
||||
)),
|
||||
array('<expr:expression> [with <arguments:array> [, <optional:expression>]]', new Twig_Grammar_Tag(
|
||||
new Twig_Grammar_Expression('expr'),
|
||||
new Twig_Grammar_Optional(
|
||||
new Twig_Grammar_Constant('with'),
|
||||
new Twig_Grammar_Array('arguments'),
|
||||
new Twig_Grammar_Optional(
|
||||
new Twig_Grammar_Constant(','),
|
||||
new Twig_Grammar_Expression('optional')
|
||||
)
|
||||
)
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user