Along w/ the problem of unbalancing tags there is also the white space issue (e.g. you want 100 characters you could have 'a' . $ninety_five_spaces . 'b' . $tons_of_text. and the truncated verbiage is essencially 'a b'
length of character entities (e.g < == 1 character not 4) Fortunately it looks like someone has already addressed all of that for us :) http://search.cpan.org/perldoc?HTML::Truncate On Apr 10, 2009, at 3:38 AM, Nicolas Ramz wrote: > Hi, > > I have a variable which contains some HTML text which may contain > some tags, like <strong> or <p> and I'd like to truncate it. The > problem is that truncate doesn't preserve the HTML tags, so this can > break my page, like in this example: > > $foo = "<p>blablablabla foooo</p>" > > in my template: > > [% FILTER truncate(10, '...') %] > [% foo | html %] > [% END%] > > => the <p> isn't closed anymore. > > Is there a function that would allow to do that ? Or an easy way to > do so ? > > Thanks! > > Leo. > _______________________________________________ > templates mailing list > [email protected] > http://mail.template-toolkit.org/mailman/listinfo/templates _______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
