mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 12:37:15 +00:00
bug #3075 [1.x] Patch split filter (adriansuter)
This PR was squashed before being merged into the 1.x branch (closes #3075).
Discussion
----------
[1.x] Patch split filter
This PR addresses #3072 vor Twig 1.x.
Commits
-------
4c4df962 [1.x] Patch split filter
This commit is contained in:
@@ -790,7 +790,7 @@ function twig_join_filter($value, $glue = '', $and = null)
|
||||
*/
|
||||
function twig_split_filter(Environment $env, $value, $delimiter, $limit = null)
|
||||
{
|
||||
if (!empty($delimiter)) {
|
||||
if (strlen($delimiter)) {
|
||||
return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
{{ baz|split('', 1)|join('-') }}
|
||||
{{ baz|split('', 2)|join('-') }}
|
||||
{{ foo|split(',', -2)|join('-') }}
|
||||
{{ "hello0world"|split('0')|join('-') }}
|
||||
--DATA--
|
||||
return ['foo' => "one,two,three,four,five", 'baz' => '12345',]
|
||||
--EXPECT--
|
||||
@@ -17,4 +18,5 @@ one-two-three,four,five
|
||||
1-2-3-4-5
|
||||
1-2-3-4-5
|
||||
12-34-5
|
||||
one-two-three
|
||||
one-two-three
|
||||
hello-world
|
||||
Reference in New Issue
Block a user