From: Christophe Coevoet Date: Mon, 12 Mar 2012 13:56:44 +0000 (+0100) Subject: Added a trim filter X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=d942d11f2f237735081aae5edc985c9728f6cb4f;p=konrad%2Ftwig.git Added a trim filter Closes #634 --- diff --git a/CHANGELOG b/CHANGELOG index 03ab25a..92313b7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +* 1.7.0 (2012-XX-XX) + + * added a trim filter + * 1.6.1 (2012-02-29) * fixed Twig C extension diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index f585b65..81bbb1f 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -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 diff --git a/test/Twig/Tests/Fixtures/filters/trim.test b/test/Twig/Tests/Fixtures/filters/trim.test new file mode 100644 index 0000000..3192062 --- /dev/null +++ b/test/Twig/Tests/Fixtures/filters/trim.test @@ -0,0 +1,12 @@ +--TEST-- +"trim" filter +--TEMPLATE-- +{{ " I like Twig. "|trim }} +{{ text|trim }} +{{ " foo/"|trim("/") }} +--DATA-- +return array('text' => " If you have some HTML it will be escaped. ") +--EXPECT-- +I like Twig. +If you have some <strong>HTML</strong> it will be escaped. + foo