mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
fixed length in modifier.truncate.php
This commit is contained in:
1
NEWS
1
NEWS
@@ -1,3 +1,4 @@
|
|||||||
|
- fixed length in modifier.truncate.php (messju)
|
||||||
- fixed handling of '$'-signs in trimwhitespace outputfilter (messju)
|
- fixed handling of '$'-signs in trimwhitespace outputfilter (messju)
|
||||||
- fix bug that makes config files recompile every time
|
- fix bug that makes config files recompile every time
|
||||||
(Nagger, Monte)
|
(Nagger, Monte)
|
||||||
|
@@ -18,12 +18,10 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
|||||||
|
|
||||||
if (strlen($string) > $length) {
|
if (strlen($string) > $length) {
|
||||||
$length -= strlen($etc);
|
$length -= strlen($etc);
|
||||||
$fragment = substr($string, 0, $length+1);
|
if (!$break_words)
|
||||||
if ($break_words)
|
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
|
||||||
$fragment = substr($fragment, 0, -1);
|
|
||||||
else
|
return substr($string, 0, $length).$etc;
|
||||||
$fragment = preg_replace('/\s+(\S+)?$/', '', $fragment);
|
|
||||||
return $fragment.$etc;
|
|
||||||
} else
|
} else
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user