projects
/
web/konrad/twig.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
(parent:
5b5de2c
)
Fixed slice filter w/ null length for string values
author
Sylvain Dethier
<sv1l.net@gmail.com>
Sun, 5 Feb 2012 17:37:26 +0000 (18:37 +0100)
committer
Sylvain Dethier
<sv1l.net@gmail.com>
Sun, 5 Feb 2012 17:37:26 +0000 (18:37 +0100)
lib/Twig/Extension/Core.php
patch
|
blob
|
history
diff --git
a/lib/Twig/Extension/Core.php
b/lib/Twig/Extension/Core.php
index
829eb43
..
9c5f9c2
100644
(file)
--- a/
lib/Twig/Extension/Core.php
+++ b/
lib/Twig/Extension/Core.php
@@
-550,8
+550,16
@@
function twig_slice(Twig_Environment $env, $item, $start, $length = null)
$item = (string) $item;
if (function_exists('mb_get_info') && null !== $charset = $env->getCharset()) {
+ if (null === $length) {
+ $length = mb_strlen($item, $charset) - $start;
+ }
+
return mb_substr($item, $start, $length, $charset);
}
+
+ if (null === $length) {
+ return substr($item, $start);
+ }
return substr($item, $start, $length);
}