added null as an alias to none and made TRUE, FALSE, and NONE equivalent to true, false, and none

This commit is contained in:
Fabien Potencier
2011-04-14 07:35:58 +02:00
parent 385dc39689
commit 76205f1eaa
3 changed files with 29 additions and 0 deletions
+2
View File
@@ -4,6 +4,8 @@ Flush your cache after upgrading.
Changes:
* added null as an alias for none
* made TRUE, FALSE, NONE equivalent to their lowercase counterparts
* wrapped all runtime exceptions with Twig_Error_Runtime and added logic to guess the template name and line
* moved display() method to Twig_Template (generated templates should now use doDisplay() instead)
+5
View File
@@ -117,14 +117,19 @@ class Twig_ExpressionParser
$this->parser->getStream()->next();
switch ($token->getValue()) {
case 'true':
case 'TRUE':
$node = new Twig_Node_Expression_Constant(true, $token->getLine());
break;
case 'false':
case 'FALSE':
$node = new Twig_Node_Expression_Constant(false, $token->getLine());
break;
case 'none':
case 'NONE':
case 'null':
case 'NULL':
$node = new Twig_Node_Expression_Constant(null, $token->getLine());
break;
@@ -0,0 +1,22 @@
--TEST--
Twig supports literals
--TEMPLATE--
1 {{ true }}
2 {{ TRUE }}
3 {{ false }}
4 {{ FALSE }}
5 {{ none }}
6 {{ NONE }}
7 {{ null }}
8 {{ NULL }}
--DATA--
return array()
--EXPECT--
1 1
2 1
3
4
5
6
7
8