ad_string_truncate_middle (public)

 ad_string_truncate_middle [ -ellipsis ellipsis ] [ -len len ] string

Defined in packages/acs-tcl/tcl/text-html-procs.tcl

Cut middle part of a string in case it is too long.

Switches:
-ellipsis (optional, defaults to "...")
placeholder for the portion of text being left out
-len (optional, defaults to "100")
length after which we are starting cutting text
Parameters:
string (required)
Returns:
truncated string
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_string_truncate_middle ad_string_truncate_middle (test xotcl-request-monitor) ad_string_truncate_middle ad_string_truncate_middle test_ad_string_truncate_middle->ad_string_truncate_middle packages/xotcl-request-monitor/www/last-requests.tcl packages/xotcl-request-monitor/ www/last-requests.tcl packages/xotcl-request-monitor/www/last-requests.tcl->ad_string_truncate_middle packages/xotcl-request-monitor/www/stat-details.tcl packages/xotcl-request-monitor/ www/stat-details.tcl packages/xotcl-request-monitor/www/stat-details.tcl->ad_string_truncate_middle string_truncate_middle string_truncate_middle (public, deprecated) string_truncate_middle->ad_string_truncate_middle

Testcases:
ad_string_truncate_middle
Source code:
    set string [string trim $string]
    if {[string length $string]>$len} {
        set half  [expr {($len-2)/2}]
        set left  [string trimright [string range $string 0 $half]]
        set right [string trimleft  [string range $string end-$half end]]
        return $left$ellipsis$right
    }
    return $string
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: