Using HomeSite
|
|
Chapter 7 : Editing Pages
|
Preserving Code Formats with CodeSweepers
The CodeSweeper feature automates the task of getting your code properly formatted. It can be very useful in a number of situations:
- Visually editing page elements in Design view can change code formatting. You can set CodeSweeper to apply formatting rules when you leave Design view.
- You can painlessly enforce coding styles for multiple developers by simply having them use the same settings.
- You can easily clean up the code formatting of an existing project as you review the documents.
HomeSite includes a number of CodeSweepers for you to use. You can also create your own CodeSweepers or edit the existing ones. HomeSite CodeSweepers include:
- HTML and CFML tags (default) -- Formats ColdFusion applications.
- HTML tags only -- Optimized for standard Web pages.
- My CodeSweeper -- A copy of the default CodeSweeper that you can use for testing.
- WDDX Sweeper -- Formats code written in WDDX, for example, the .apd files used to store project information.
- HTML Tidy -- An independent open source code HTML verifier and formatter that you can use as an alternative to the native CodeSweeper. It also enables the conversion of HTML to an XML-compliant XHTML. See the HTML Tidy settings section below for details.
See the Allaire Developer site for an interesting article on CodeSweeper features.
Setting and using the default CodeSweeper
Click the CodeSweeper button from either Edit or Design modes to run the default CodeSweeper on the current document. You can also set the default CodeSweeper to run automatically when you leave Design mode.
 |
To set the default CodeSweeper:
|
- From the Options menu, choose Settings (F8) to see the Settings dialog box.
- Click CodeSweeper to see the CodeSweepers pane.
- Select the CodeSweeper that you want to use as the default from the list and click Set as Default.
- Click OK.
 |
To run a CodeSweeper automatically after leaving Design mode:
|
- In the Settings dialog box (F8), click Design.
- Click Apply CodeSweeper when return from design view.
- Click OK.
Using a CodeSweeper other than the default
You can use a CodeSweeper other than the default at any time. Changes are made to the current document only.
 |
To use a CodeSweeper other than the default:
|
- Click the down arrow on the CodeSweeper button, or choose Tools > CodeSweeper and choose from the list of available CodeSweepers.
You are notified that the CodeSweeper will format the entire document and
cannot be undone.
- Click Run CodeSweeper.
The document is formatted.
Creating, editing, and removing CodeSweepers
You can create new CodeSweepers, edit existing CodeSweepers, and remove outdated CodeSweepers using the Settings dialog box (F8).
 |
To create a new CodeSweeper:
|
- Open the Settings dialog box (F8).
- Click CodeSweeper to see the CodeSweepers pane.
- Click New Profile to see the New CodeSweeper Profile dialog box.
- Enter a name for the CodeSweeper and choose its type: Allaire CodeSweeper or HTML Tidy CodeSweeper.
- Click OK.
The CodeSweeper is added to the list.
- Follow the directions below to edit the CodeSweeper to fulfill your needs.
 |
To edit a CodeSweeper:
|
- In the Settings dialog box (F8), expand CodeSweeper.
- Expand the node for the type of CodeSweeper you want to edit: Allaire CodeSweepers or HTML Tidy CodeSweepers.
- Select the CodeSweeper you want to edit to see the CodeSweeper settings.
- Make any changes to the settings and click OK.
 |
To remove a CodeSweeper:
|
- In the Settings dialog box (F8), click CodeSweeper.
- Select the CodeSweeper you want to remove from the list on the right and click Remove Profile.
The CodeSweeper is removed without warning.
CodeSweeper settings
There are three types of CodeSweeper settings:
- General settings and Tag-specific settings can be set for each Allaire CodeSweeper. Note that general settings are not global. You can specify different general settings for each CodeSweeper.
- HTML Tidy settings apply to HTML Tidy CodeSweepers only.
General settings
You can set the following formatting rules for each Allaire CodeSweeper.
- Set case for tag and attribute names. You can choose all upper or lower case or preserve case, which leaves the case unchanged.
- The Format event names setting contains an additional option - Mixed Case -which applies to case-sensitive JavaScript event handler names like OnMouseOver. If this code is correct in your document, select Preserve Case for this setting.
- Set the use of quotes for values.
- Trim white space between tags cleans up spacing produced by some code generation tools. It is enabled by default. We recommend leaving it on and disabling it for individual tags as needed.
- Run in "Silent Mode" to eliminate any alerts the CodeSweeper would generate while it is running. You can use this option to run a CodeSweeper in an unattended situation.
- Check Write Errors to a Log File to capture any errors found by the CodeSweeper. You can specify a custom location for the log file.
Click the OK button to save these settings.
Tag-specific settings
A wide range of options is available for the individual tags contained in each Allaire CodeSweeper. Note that if you set formatting for the "All Other Tags" entry in the tag list, those rules apply to every tag that appears in a document that is not in the list.
- Insert a newline command for start and end tags.
- Set indent by tabs or spaces -- a newline is inserted automatically for each indented line when this option is checked.
- Enable indenting of nested sub-tags.
- Override the general trim white space setting by preventing trimming of white space around the selected tag.
- Leave the selected tag unchanged when invoking CodeSweeper.
- Strip tag from document -- this is handy for getting rid of superfluous and unwanted tags inserted by code generation tools.
 |
To set rules for a tag:
|
- Select a tag from the Tag Specific Settings list in the CodeSweeper Settings dialog box.
- Change the specific settings.
- Click Update Tag to save the settings for that tag.
 |
To add a tag:
|
- Click the Add Tag button in the CodeSweeper Settings dialog box.
- Enter the tag name and click OK.
- Change tag settings and click Update Tag to save the settings.
 |
To remove a tag:
|
- Select a tag from the Tag Specific Settings list in the CodeSweeper Settings dialog box.
- Click Remove Tag.
- Click OK to close the Settings dialog box.
HTML Tidy settings
The HTML Tidy author's Web site is http://www.w3.org/People/Raggett/tidy/. You can access this Web site from the HTML Tidy Settings pane. Refer to this site for detailed descriptions of all the HTML Tidy settings in the Settings dialog box.
Creating a custom profile
You can create your own custom configuration text file and save it with a .tdy extension to the your \extensions\Codesweepers folder.
Copyright © 1999, Allaire Corporation. All rights reserved.
|
|