I’m working on a plugin for Trac and am inserting some javascript into the rendered HTML by manipulating the Genshi stream.
I need to test if a javascript function is already in the HTML and if it is then overwrite it with a new version, if it isn’t then add it to the HTML.
How do I perform a search to see if the function is already there?
Aha!! I have solved this by first attempting to remove the function from the stream:
and then adding the updated/new version: