This is the code. I quickly cut/paste the entry with bad data.
[% truncate_txt = String.new(dailynews).truncate(500, '...') %]
[% truncate_txt = truncate_txt.replace("<div>","<p>"); %]
[% truncate_txt = truncate_txt.replace("</div>","</p>"); %]
[% truncate_txt %]
--- On Fri, 4/17/09, Summer <[email protected]> wrote:
From: Summer <[email protected]>
Subject: reg expression and omitting div tags
To: [email protected]
Date: Friday, April 17, 2009, 5:27 PM
Hello,
I have the following code:
[% truncate_txt = String.new(dailynews).truncate(500, '...') %]
[% trunc_txt = trunc_synopsis.replace("<div>","<p>"); %]
[% trunc_txt = trunc_synopsis.replace("</div>","</p>"); %]
[% trunc_txt %]
This isnt' working well. Basically, users will sometimes put div tags IN the
stories and I can't have that because when I truncate, I potentially cut off
closing div tags.
I was thinking I would just replace the div tags with paragraph tags. BUT what
I have doesn't seem to work either. I mean, P gets put in, but its not clean.
Alot of closing P's get put in even when I don't close the DIVS
Is there a robust solution that IF there are any DIV, irregardless of
captilization etc.. a corresponding P tag will be used.. for example.
When I find a <div> or a
<DIV> or <DIv> it will be replaced with a <p>. Same with a closing div???
Please advise.
Bill
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates