mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-05 06:56:51 +00:00
fixed in operator for empty strings
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user