1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
--TEST--
"trim" filter
--TEMPLATE--
{{ " I like Twig. "|trim }}
{{ text|trim }}
{{ " foo/"|trim("/") }}
{{ "xxxI like Twig.xxx"|trim(character_mask: "x", side: "left") }}
{{ "xxxI like Twig.xxx"|trim(side: "right", character_mask: "x") }}
{{ "xxxI like Twig.xxx"|trim("x", "right") }}
{{ "/ foo/"|trim("/", "left") }}
{{ "/ foo/"|trim(character_mask: "/", side: "left") }}
{{ " do nothing. "|trim("", "right") }}
*{{ ""|trim }}*
*{{ ""|trim("", "left") }}*
*{{ ""|trim("", "right") }}*
*{{ null|trim }}*
*{{ null|trim("", "left") }}*
*{{ null|trim("", "right") }}*
{% set myhtml %}
Here is<br>my HTML
{% endset %}
{% set myunsafestring = " I <3 u " %}
{{ myhtml | trim }}
{{ myunsafestring | trim }}
{{ myhtml | trim(character_mask: "f") }}
--DATA--
return ['text' => " If you have some <strong>HTML</strong> it will be escaped. "]
--EXPECT--
I like Twig.
If you have some <strong>HTML</strong> it will be escaped.
foo
I like Twig.xxx
xxxI like Twig.
xxxI like Twig.
foo/
foo/
do nothing.
**
**
**
**
**
**
Here is<br>my HTML
I <3 u
Here is<br>my HTML
|