Added a trim filter

Closes #634
This commit is contained in:
Christophe Coevoet
2012-03-12 14:56:44 +01:00
parent c5ef990807
commit d942d11f2f
3 changed files with 17 additions and 0 deletions
+4
View File
@@ -1,3 +1,7 @@
* 1.7.0 (2012-XX-XX)
* added a trim filter
* 1.6.1 (2012-02-29)
* fixed Twig C extension
+1
View File
@@ -137,6 +137,7 @@ class Twig_Extension_Core extends Twig_Extension
'upper' => new Twig_Filter_Function('strtoupper'),
'lower' => new Twig_Filter_Function('strtolower'),
'striptags' => new Twig_Filter_Function('strip_tags'),
'trim' => new Twig_Filter_Function('trim'),
'nl2br' => new Twig_Filter_Function('nl2br', array('pre_escape' => 'html', 'is_safe' => array('html'))),
// array helpers
@@ -0,0 +1,12 @@
--TEST--
"trim" filter
--TEMPLATE--
{{ " I like Twig. "|trim }}
{{ text|trim }}
{{ " foo/"|trim("/") }}
--DATA--
return array('text' => " If you have some <strong>HTML</strong> it will be escaped. ")
--EXPECT--
I like Twig.
If you have some &lt;strong&gt;HTML&lt;/strong&gt; it will be escaped.
foo