Re: [SMARTY-DEV] Proposed change to modifier.truncate.php to respect HTML entities

From: Date: Mon, 07 Jun 2004 20:56:29 +0000
Subject: Re: [SMARTY-DEV] Proposed change to modifier.truncate.php to respect HTML entities
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2406@lists.php.net to get a copy of this message
On Fri, Jun 04, 2004 at 05:35:41PM -0700, Bharat Mediratta wrote: > > I'm using the truncate modifier in my templates to truncate user-defined > output which can contain HTML entities. I need truncate to respect HTML > entities so that it calculates the length correctly and doesn't split on > HTML entity boundaries. > > I chose to create a new modifier based on the truncate modifier which > does the equivalent of html_entity_decode() on the input string, then > does the truncate calculation, then does an htmlentities() on the result > before returning it. This is perhaps not the most efficient approach, > but it is simple in the code (and I am not particularly concerned about > efficiency in this case). > > It would be easy for me to make this an optional behaviour in the > standard truncate modifier, preserving its existing API. If I were to > do that and provide a patch, would it be accepted? If not, is there an > alternate approach you'd prefer to get the same results? html-encoded strings are not the only problematic input to truncate. AFAIK multi-byte-character-sets can also cause probles. maybe we can find a solution that solves both? > thanks, > -Bharat

« previous php.smarty.dev (#2406) next »