added null as an alias to none and made TRUE, FALSE, and NONE equivalent to true...
authorFabien Potencier <fabien.potencier@gmail.com>
Thu, 14 Apr 2011 05:35:58 +0000 (07:35 +0200)
committerFabien Potencier <fabien.potencier@gmail.com>
Thu, 14 Apr 2011 05:35:58 +0000 (07:35 +0200)
CHANGELOG
lib/Twig/ExpressionParser.php
test/Twig/Tests/Fixtures/expressions/literals.test [new file with mode: 0644]

index 673cbe5..1d70d47 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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)
 
index 2e2b4b1..b355f08 100644 (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;
 
diff --git a/test/Twig/Tests/Fixtures/expressions/literals.test b/test/Twig/Tests/Fixtures/expressions/literals.test
new file mode 100644 (file)
index 0000000..7ae3bae
--- /dev/null
@@ -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