Summer wrote:
> When I find a <div> or a <DIV> or <DIv> it will be replaced with a <p>.
> Same with a closing div???
This is simple enough. Instead of:
[% truncate_txt = truncate_txt.replace("<div>","<p>"); %]
Use the perl regexp option to ignore case:
[% truncate_txt = truncate_txt.replace("(?i)<div>","<p>"); %]
If you need to hunt down divs with more than a simple div tag:
[% truncate_txt = truncate_txt.replace("(?i)<div[^>]*>","<p>"); %]
However, this method is still flawed. You could still cut off a p tag at a
really bad spot.
You might want to take a look at HTML::Truncate which we discussed recently on
the list:
http://search.cpan.org/~ashley/HTML-Truncate-0.16/lib/HTML/Truncate.pm
There is a filter as well:
http://search.cpan.org/~ashley/HTML-Truncate-0.16/lib/HTML/Truncate.pm#Template_Toolkit_filter
-- Josh
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates