Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
This week, we're updating our course layouts and descriptions. Presentation and materials always gently change over time, but just occasionally there's a need to make a step change to clear out some of the old and roll in the new. That's now happening - but over a long and complex site it's not instant and you'll see sections of the site changing up to and including 19th September.

See also [here] for status update
 
Replace block of HTML

Posted by TedH (TedH), 26 February 2007
I can replace single element in an html template with no problem. For example:
Code:
<div class="headline">"aaaaa"</div>
can become  
Code:
<div class="headline">"I didn't get an oscar"</div>
using a string.

What I cannot figure out is how to replace an existing block of html. Say like below.
Code:
<!--a-->
<P>Any HTML and text would be here</p>
<!--b-->

with
Code:
<!--a-->
<div>The replacement</div>
<!--b-->


Is there an easy way to do that?

The end result for this is block replacement for my blog script's closed months (I gotta get rid of those forms).

cheers - Ted

Posted by Custard (Custard), 26 February 2007
Hi Ted, hope you are well..

Can you give us a bit more background?

I'm not sure if you are using something like Template Toolkit or have your own template system.

And a bit of code would round it off nicely..

Cheers

B

Posted by TedH (TedH), 26 February 2007
Kinda made up my own
Code:
$_ =~ s/aaaaa/$input{'nf003'}/g;

Where the input replaces the aaaaa

The idea to use the
Code:
<!--a-->
<P>Any HTML and text would be here</p>
<!--b-->

was me just guessing that I needed something above and below the form to mark it out after the page has been made from the template.

Page is used for one month, then the form usage is deactivated at present, but form still there. I figured it's less confusing to remove the form entirely.

Does that make sense?

- Ted

Posted by TedH (TedH), 26 February 2007
I've tried this to see if I can extract the between the tags stuff
Code:
while (<@stuff>) {
print if m#<\!--a-->#i .. m#<\!--b-->#i;
}

While it can print to screen fine after opening the file and reading it into an array, anything else is beyond me.

It's like if the two dots could be read into an array, then it could be replaced with whatever I define.

- Ted

Posted by TedH (TedH), 26 February 2007
Custard, I may be approaching this the wrong way.

Maybe I should try matching the form then replacing it.

There could be 31 HTML files, all of which would need the form replacing. I would have to loop through the folder, read in each file, match the form and replace it for each file.

Does that make sense?

I already replace all the scripts, but with a total rewrite to deactivate them. The HTML files, though, would need to retain everything except the form. I'll give that a go and see what happens.

- Ted

Posted by TedH (TedH), 24 March 2007
Hi Custard, sorry about the delay - been up to my ears in stuff.

I still haven't got anywhere on this, but have put it on hold until for a bit.

How are things your end?

cheers - Ted



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho