Proposed change to modifier.truncate.php to respect HTML entities
Bharat Mediratta <[email protected]>
| Newsgroups | gmane.comp.php.smarty.devel |
|---|---|
| Message-ID | <[email protected]> |
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? thanks, -Bharat -- Smarty Development Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php