[interchange-cvs] interchange - heins modified
lib/Vend/Interpolate.pm
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Mon Apr 19 17:59:07 EDT 2004
User: heins
Date: 2004-04-19 21:59:07 GMT
Modified: lib/Vend Interpolate.pm
Log:
* Add NN$ to the filter spec for length, shows only last NN characters
of string preceded by a fake ... ellipsis.
[filter 10]A long string that needs truncating.[/filter]
[filter 10.]A long string that needs truncating.[/filter]
[filter 10$]A long string that needs truncating.[/filter]
Produces
A long str
A long str...
...runcating.
I thought about .NN, but it didn't seem as logical to my Perlish mind.
Revision Changes Path
2.209 +16 -5 interchange/lib/Vend/Interpolate.pm
rev 2.209, prev_rev 2.208
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.208
retrieving revision 2.209
diff -u -r2.208 -r2.209
--- Interpolate.pm 13 Apr 2004 01:10:14 -0000 2.208
+++ Interpolate.pm 19 Apr 2004 21:59:07 -0000 2.209
@@ -1,6 +1,6 @@
# Vend::Interpolate - Interpret Interchange tags
#
-# $Id: Interpolate.pm,v 2.208 2004/04/13 01:10:14 jon Exp $
+# $Id: Interpolate.pm,v 2.209 2004/04/19 21:59:07 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -28,7 +28,7 @@
require Exporter;
@ISA = qw(Exporter);
-$VERSION = substr(q$Revision: 2.208 $, 10);
+$VERSION = substr(q$Revision: 2.209 $, 10);
@EXPORT = qw (
@@ -605,9 +605,20 @@
$value = sprintf($_, $value);
next;
}
- if (/^(\d+)(\.?)$/) {
- substr($value, $1) = $2 ? '...' : ''
- if length($value) > $1;
+ if (/^(\d+)([\.\$]?)$/) {
+ my $len;
+ return $value unless ($len = length($value)) > $1;
+ my ($limit, $mod) = ($1, $2);
+ unless($mod) {
+ substr($value, $limit) = '';
+ }
+ elsif($mod eq '.') {
+ substr($value, $1) = '...';
+ }
+ elsif($mod eq '$') {
+ substr($value, 0, $len - $limit) = '...';
+ }
+ return $value;
next;
}
while( s/\.([^.]+)$//) {
More information about the interchange-cvs
mailing list