* the odd and even filters are now tests:
{{ foo|odd }} must now be written {{ foo is odd }}
+ * fixed objects with __toString() not being autoescaped
* fixed subscript expressions when calling __call() (methods now keep the case)
* added a "trans" filter
* added "test" feature (accessible via the "is" operator)
*/
function twig_escape_filter(Twig_Environment $env, $string, $type = 'html')
{
- if (!is_string($string)) {
+ if (!is_string($string) && !(is_object($string) && method_exists($string, '__toString'))) {
return $string;
}
{% autoescape on %}
{{ user.name }}
{{ user.name|lower }}
+{{ user }}
{% endautoescape %}
--DATA--
class UserForAutoEscapeTest
{
return 'Fabien<br />';
}
+
+ public function __toString()
+ {
+ return 'Fabien<br />';
+ }
}
return array('user' => new UserForAutoEscapeTest())
--EXPECT--
Fabien<br />
fabien<br />
+Fabien<br />