mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-10 17:36:53 +00:00
changed the precedence of the .. operator
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 1.4.0
|
||||
|
||||
* changed the precedence of the .. operator to be more consistent with languages that implements such a feature like Ruby
|
||||
* added an Exception to Twig_Loader_Array::isFresh() method when the template does not exist to be consistent with other loaders
|
||||
* added Twig_Function_Node to allow more complex functions to have their own Node class
|
||||
* added Twig_Filter_Node to allow more complex filters to have their own Node class
|
||||
|
||||
@@ -149,6 +149,7 @@ class Twig_Extension_Core extends Twig_Extension
|
||||
'<=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'not in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotIn', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_In', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'..' => array('precedence' => 25, 'class' => 'Twig_Node_Expression_Binary_Range', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'+' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Add', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'-' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Sub', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'~' => array('precedence' => 40, 'class' => 'Twig_Node_Expression_Binary_Concat', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
@@ -158,7 +159,6 @@ class Twig_Extension_Core extends Twig_Extension
|
||||
'%' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'is' => array('precedence' => 100, 'callable' => array($this, 'parseTestExpression'), 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'is not' => array('precedence' => 100, 'callable' => array($this, 'parseNotTestExpression'), 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'..' => array('precedence' => 110, 'class' => 'Twig_Node_Expression_Binary_Range', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'**' => array('precedence' => 200, 'class' => 'Twig_Node_Expression_Binary_Power', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -8,10 +8,13 @@ Twig supports the .. operator
|
||||
{% for letter in 'a'|upper..'z'|upper %}{{ letter }} {% endfor %}
|
||||
|
||||
{% for i in foo[0]..foo[1] %}{{ i }} {% endfor %}
|
||||
|
||||
{% for i in 0 + 1 .. 10 - 1 %}{{ i }} {% endfor %}
|
||||
--DATA--
|
||||
return array('foo' => array(1, 10))
|
||||
--EXPECT--
|
||||
0 1 2 3 4 5 6 7 8 9 10
|
||||
a b c d e f g h i j k l m n o p q r s t u v w x y z
|
||||
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
|
||||
1 2 3 4 5 6 7 8 9 10
|
||||
1 2 3 4 5 6 7 8 9 10
|
||||
1 2 3 4 5 6 7 8 9
|
||||
|
||||
Reference in New Issue
Block a user