mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 10:56:38 +00:00
Merge branch '2.x' into 3.x
* 2.x: fixed CS [1.x] Patch split filter [doc] "map" filter: fix args order (value, key)
This commit is contained in:
+1
-1
@@ -23,7 +23,7 @@ The arrow function also receives the key as a second argument:
|
||||
"Alice": "Dupond",
|
||||
} %}
|
||||
|
||||
{{ people|map((first, last) => "#{first} #{last}")|join(', ') }}
|
||||
{{ people|map((last, first) => "#{first} #{last}")|join(', ') }}
|
||||
{# outputs Bob Smith, Alice Dupond #}
|
||||
|
||||
Note that the arrow function has access to the current context.
|
||||
|
||||
@@ -740,7 +740,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) > 0) {
|
||||
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