That's right, get your bootstraps laced up and put your helmets on — we are marching onward, a mission to search out the rogue code in all your directories, folders, files, documents, and web pages. Okay, maybe not all of your code has rascally elements, tags, or attributes, but when was the last time you checked your directories for files containing outdated code? Maybe you have deprecated code. Remember the HTML 4.01 specification put forth by the W3C? Maybe you have code that needs to be replaced and revisions have been put on the back burner. Or maybe you have redundant, outdated, or trivial content, and it needs to be scoured and removed.
Finding and replacing large amounts of code takes some work, and you can manually streamline the purging or replacing of this code faster with these quick steps using Dreamweaver. Our weapon of choice, the Find and Replace Strip Tag.A word of caution: Whatever your sandbox, make sure you play nice; so before you start with replacing or deleting any code in your directories, documents, and files, you will want to make sure they are backed up on a development server, or copied from your production or staging environments to a local non-published drive or directory. Preparation before the mission is important!
1. Open Dreamweaver.2. From the Edit menu select Find and Replace (CTRL+F) (Figure A ).
3. The default Find and Replace dialog box opens and there are several options. The simplest is finding within the current document any source code with the usual find and replace options. But what if you want to search more than one document, or how about code that has attributes also? You want to get rid of all that code, not just the <font> element, for example, but all the associated attributes along with the code. The Find In: options include the default Current Document, Selected Text, Open Documents, Folder..., Selected Files in Site, and Entire Current Local Site. These options provide the ability to scour from the single document level to the entire site level, a broad range of choices.
4. Let's say we want to search for deprecated code that references the <font> tag and any references to it with attributes as well. Instead of just a single document, I want to search the entire site for any occurrence with the <font> tag. Before I start this process, I am going to copy my suspicious documents to a new folder and name it Suspects. Straight-forward, right? We are on a mission, remember! You can organize the suspect files and directories depending on your situation, as long as you remember where they are to be returned after stripping out or replacing the code.5. We will select the Folder... option in the Find In drop-down menu, since I've gone the route of rounding up all the dubious documents, shown in Figure B. Then, click the Choose Folder Search icon and browse to the Suspect folder and click Select. It's the little folder icon just to the right of the text field.
10. All the document files will be stripped of "all" <font> tags and automatically saved once the process is completed.
Once you get comfortable using the Strip Tag feature in Find and Replace, you will want to expand, using and stripping other tags and content from entire local sites.
Do you have any tips for striping out or replacing rogue code in your implementations?
Ryan has performed in a broad range of technology support roles for electric-generation utilities, including nuclear power plants, and for the telecommunications industry. He has worked in web development for the restaurant industry and the Federal government.