* 1.6.0-DEV
+ * fixed the empty test and the length filter for Twig_Markup instances
* added a date function to ease date comparison
* fixed unary operators precedence
* @package twig
* @author Fabien Potencier <fabien@symfony.com>
*/
-class Twig_Markup
+class Twig_Markup implements Countable
{
protected $content;
{
return $this->content;
}
+
+ public function count()
+ {
+ return strlen($this->content);
+ }
}
{{ array|length }}
{{ string|length }}
{{ number|length }}
+{{ markup|length }}
--DATA--
-return array('array' => array(1, 4), 'string' => 'foo', 'number' => 1000)
+return array('array' => array(1, 4), 'string' => 'foo', 'number' => 1000, 'markup' => new Twig_Markup('test'))
--EXPECT--
2
3
4
+4
{{ string is empty ? 'ok' : 'ko' }}
{{ countable_empty is empty ? 'ok' : 'ko' }}
{{ countable_not_empty is empty ? 'ok' : 'ko' }}
+{{ markup_empty is empty ? 'ok' : 'ko' }}
+{{ markup_not_empty is empty ? 'ok' : 'ko' }}
--DATA--
class CountableStub implements Countable
return count($this->items);
}
}
-return array('foo' => '', 'bar' => null, 'foobar' => false, 'array' => array(), 'zero' => 0, 'string' => '0', 'countable_empty' => new CountableStub(array()), 'countable_not_empty' => new CountableStub(array(1, 2)));
+return array(
+ 'foo' => '', 'bar' => null, 'foobar' => false, 'array' => array(), 'zero' => 0, 'string' => '0',
+ 'countable_empty' => new CountableStub(array()), 'countable_not_empty' => new CountableStub(array(1, 2)),
+ 'markup_empty' => new Twig_Markup(''), 'markup_not_empty' => new Twig_Markup('test'),
+);
--EXPECT--
ok
ok
ko
ko
ok
-ko
\ No newline at end of file
+ko
+ok
+ko