fixed in operator for empty strings

This commit is contained in:
Fabien Potencier
2011-10-29 14:50:10 +02:00
parent dc15afabb8
commit dfdd555b9a
3 changed files with 12 additions and 0 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.4.0
* fixed in operator for empty strings
* fixed the "defined" test and the "default" filter (now works with more than one call (foo.bar.foo) and for both values of the strict_variables option)
* changed the way extensions are loaded (addFilter/addFunction/addGlobal/addTest/addNodeVisitor/addTokenParser/addExtension can now be called in any order)
* added Twig_Environment::display()
+3
View File
@@ -443,6 +443,9 @@ function twig_in_filter($value, $compare)
if (is_array($compare)) {
return in_array($value, $compare);
} elseif (is_string($compare)) {
if (!$compare) {
return empty($value);
}
return false !== strpos($compare, (string) $value);
} elseif (is_object($compare) && $compare instanceof Traversable) {
return in_array($value, iterator_to_array($compare, false));
@@ -12,9 +12,17 @@ TRUE
{% else %}
TRUE
{% endif %}
{% if '' not in foo %}
TRUE
{% endif %}
{% if '' in '' %}
TRUE
{% endif %}
--DATA--
return array('bar' => 'bar', 'foo' => array('bar' => 'bar'))
--EXPECT--
TRUE
TRUE
TRUE
TRUE
TRUE