Extended Dreamweaver: Parsing of custom Third-party tags

Source: Internet
Author: User
Tags format define definition empty tag name valid visibility dreamweaver
Dreamweaver

Because recently has been doing the development of Dreamweaver Plug-ins, Chinese information is very few, their English is poor, when viewing English information is not a headache. It is only when you have to translate some of the important content into Chinese that you will find it refreshing. This excerpt from the Dreamweaver 8 with the "Extending Dreamweaver 8", translation of the time reference to the knight of the island translation of "Dreamweaver 4 Chinese help." But frankly, I'm a little skeptical that some parts of that help are translated with software such as Jinshan fast translation, which is harder to read than English.

Server-side technologies, such as ASP, Macromedia Coldfusion,jsp, and PHP use special non-HTML syntax in HTML files, the server creates and provides HTML-formatted content based on these codes. When Dreamweaver detects non-HTML tags, Dreamweaver invokes a third-party tag's definition file to compare them, which specifies how Dreamweaver reads and displays the labels.

For example, in addition to the standard HTML language, ASP files also contain ASP code for server resolution. The ASP code looks like an HTML tag, which is labeled by a pair of tags, starting with the <% and closing the%> In the Dreamweaver Configuration/thirdpartytags folder there is a file called Tags.xml, which describes the various Third-party label specifications including ASP, and defines the Dreamweaver How to display the code. Using this method, the ASP code has been tags.xml in the system, so Dreamweaver will not try to parse any code between <%...%>. In Design view, however, it displays an icon to indicate that this is an ASP code. You can define your own tags and create a new tag library file for each set of tags to specify how Dreamweaver reads and displays your tags.

Note: This section explains how to define how Dreamweaver displays a custom label, but does not describe how to edit the contents or attributes of a custom label. How to create a property inspector to check and modify the properties of a custom label, look at the property inspector for relevant information.

Each tag library file defines the name, type, content mode, display specification, and icon for one or more custom labels. You can create any number of tag library files, but they must be in the Configuration/thirdpartytags folder to be read and processed by Dreamweaver. The tag library file uses an. xml file name extension.

Tip: If you're working on several different web sites at the same time (assuming you're a freelancer), you can define all the label specifications in a single file and store it on a special site that will be maintained by someone else in the future. You can completely hand over the tag library including the custom icon and the property inspector to him.

You need to use an XML tag named Tagspec to define a label specification. For example, the following code represents a label specification named Happy.

<tagspec tag_name= "Happy" tag_type= "nonempty" render_contents= "false" content_model= "Marker_model" icon= " Happy.gif "icon_width=" icon_height= "a" ></tagspec>


You can use Tagspec to define two types of tags:
· Plain tags in HTML format
The Happy label example is a plain label in HTML format. It starts with the

• String-defined labels
A string-delimited label begins with a string and ends with another string, which is similar to an HTML empty tag (such as an IMG) because they contain neither content nor closing tags. If Happy is also a string-delimited label, then its definition specification must include start_string and end_string two attributes. ASP tags are string-delimited labels that start at <%, end at%>, and do not close the label.

The following information lists the properties and valid values for the TAGSPEC tag. A property with an asterisk ("*") represents a label that does not apply to a string definition, and an optional attribute is identified by a brace ({}), and it is not difficult to infer that other features that are not identified with curly braces are required.

<tagspec>

Description

About the default information for third party labels

Property

Tag_name,{tag_type},{render_contents},{content_model},{start_string},{end_string},{detect_in_attribute},{parse _attributes},icon,icon_width,icon_height,{equivalent_tag},{is_visual},{server_model}

tag_name represents a custom name. For a string-delimited label, Tag_name is used only to detect whether a particular property inspector applies to this label. If the first line of the property inspector contains the tag name and is marked with an asterisk ("*") in a position that conforms to the specification (in fact, in the declaration of the first line), then the inspector will be allowed to check the label for that type. For example, the tag name of ASP code is ASP, the inspector that allows checking ASP code must contain *asp* in the first line. For information about the property Inspector API, refer to the property inspector.

Tag_type Determines whether the tag is empty (as the IMG mentioned earlier) or allows the content to be placed between the beginning and closing tags (like the code tag). This attribute is necessary for normal (non-string-delimited) labels, but the labels that define the strings do not take effect because they are always empty. Valid values include "Empty" and "nonempty".

render_contents Determines whether the label displays content or replaces it with a specific icon in Design view. This property is only necessary for non-null labels and does not take effect for empty labels (the empty label itself has no content to display). This property applies only to labels that are inserted outside the property, and if a label is inserted into the property value of another label, its contents will not be displayed (this paragraph is a bit difficult to understand, I think of RealMedia, Flash, and so on, those param tags?) )。 The valid value is "true" or "false."

Content_model describes what kind of content the tag can contain, and where the tag can be inserted into the HTML file. Valid values include "Block_model", "Head_model", "Marker_model", and "Script_model":

· Block_model indicates that the tag can contain a block object such as Div, p, and that the tag can only appear in the body area, or in other body-content tags, such as div, layer, and TD.

· Head_model indicates that the label can only contain text and can only appear in the head range.

· Marker_model indicates that the tag can contain any valid HTML code and can be placed anywhere within the HTML file. The Dreamweaver built-in HTML validation program ignores tags defined as Marker_model. However, the validation program does not ignore the contents of these tags, so although the label itself can be placed anywhere, its contents can cause errors in some parts of the HTML. For example, plain text cannot appear (except the legitimate head element) in the head area of the document, so you can't put a marker_model tag containing plain text in the head area (if you do this, you have to replace the label's content pattern with Marker_model with H Ead_model). Using the Marker_model tag will be displayed on one line (in a block element such as P or div-for example, in a paragraph), it is not recommended to use this pattern if you want the label to display its own paragraph, leaving a blank line before and after.

· Script_model lets this label be placed anywhere between the HTML tags in the document. When Dreamweaver detects a label that uses the pattern, all the contents of the label are ignored. Dreamweaver will not parse after using this tag (such as some ColdFusion tags).

start_string Specifies a delimiter as the starting point for a label defined by a string. A string-delimited label can be placed in any place where a comment can be inserted. For the code between start_string and End_string, Dreamweaver will neither parse nor encode or link. This property is required when the end_string has been defined.

end_string Specifies a separator as the end point of a label defined by a string. Again, this property is required when the start_string has been defined.

Detect_in_attribute Specifies whether to ignore all the code between start_string and End_string (or between the start and end tags, if they are not defined), regardless of whether the code inserts a property or a value between them. Its default value is "false," but in general the string-delimited label should set this value to "true". For example, the ASP label specification specifies detect_in_attribute= "true" so that if an ASP tag contains quotes inside the property value, it will be ignored by Dreamweaver.

parse_attributes Indicates whether you want to resolve the label's properties. If set to True (the default), Dreamweaver resolves these properties, and if set to "false", Dreamweaver ignores all code code that precedes ">" outside the quotation marks. For example, a label such as CFIF should set this property to "false" (because Dreamweaver cannot parse it as a combination of a pair of property names/values in a label such as <cfif A is 1>).

icon Specifies the path and file name of the icon that matches the label. This property is necessary for empty tags, and is also necessary for non-null tags that cannot be displayed in the Design view of the document window.

icon_width Specifies the pixel width of the icon.

icon_height Specifies the pixel height of the icon.

Equivalent_tag Specifies a simple HTML equivalent for some of the labels associated with the form in ColdFusion. This property cannot be used by other labels.

is_visual Specifies whether the label is visible on the page. For example, the ColdFusion label Cfgraph does not specify a value for is_visual (so use the default value of "true"), ColdFusion tag cfset specifies that the is_visual value is "false." In the "Invisible element" column of the preset dialog box, you can control the visibility of the server tag, and the visual server tag and the visibility of the Invisible server label can be set separately.

Server_model, if this property is set, indicates that the Tagspec label can only be applied to pages that belong to the specified server mode. If it is not set, Tagspec can be applied to all pages. For example, the delimiters for ASP and JSP are the same, but the TAGSPEC tag for JSP specifies that the server mode is "JSP", so when Dreamweaver detects a specific delimiter on the JSP page, it displays a JSP icon; When a phase is detected on a non-JSP page The same code, it will display the ASP icon.

Content

None (empty label).

Container

No.

Example

<tagspec tag_name= "Happy" tag_type= "nonempty" render_contents= "false" content_model= "Marker_model" icon= " Happy.gif "icon_width=" icon_height= "a" ></tagspec>

How custom labels appear in Design view

The way in which a custom label appears in the Design view of the document window determines the value of the Tag_type property and the Render_contents property of the Tagspec label (see Custom Third-party label parsing). If the value of Tag_type is "empty", the specified icon defined by the Icon property is displayed. If the value of Tag_type is "nonempty", but the render_contents value is "false", the icon is also displayed as an empty label. The following example shows how an instance of the happy tag we just defined can be inserted into the HTML code:

<p>this is a paragraph that includes a instance of the <code>happy</code>tag (

Because the render_contents has been set to "false" in the label specification, the Happy label (word Joe) will not be displayed, and the Start and close tabs, including the contents between them, will be replaced with a simple icon.

For a non-empty label with a render_contents value of "true", Design view does not display it as an icon, but rather shows the content between the start and close tabs (such as the text between tags, like this: <mytag> here is the beginning and closing of the label between the contents </mytag>). If the View > Visual Assistant > Invisible element is already selected in the menu option, the content will be highlighted using the Third-party label color specified by the Code color argument ("code color" applies only to labels defined by the tag library file)

How to change the highlight color for third party labels:

1, select the Edit > Preferences in the menu options, and then select the Code Color column.
2. Click on the Third Party label color box to display the color selector.
3, select a color, and then click OK and close the Preset dialog box. For more information on how to choose colors, see also using Dreamweaver.

Avoid overwriting third party labels

Dreamweaver will correct some specific errors in the HTML code, please refer to the use of Dreamweaver for more information. By default, Dreamweaver disables the change of HTML code in files of a specific file name extension, including. asp (ASP),. CFM (ColdFusion),. JSP (JSP), and. PHP (PHP). The default setting is to ensure that Dreamweaver does not accidentally modify any code contained within a non-HTML tag. You can change the default rewrite behavior of Dreamweaver so that you can overwrite the HTML code when you open such a file, and you may add other file types in the Dreamweaver list of file types that are forbidden to overwrite.

When you enter certain special characters into the property inspector, Dreamweaver will encode them into numeric values. In general, it is best to allow Dreamweaver to execute this encoding because these special characters may be better displayed when crossing different platforms and browsers. However, because this encoding affects third-party tags, you may want to change the encoding behavior of Dreamweaver when you edit files that include third-party tags.

Allows Dreamweaver to overwrite HTML in more types of files:

1, select the Edit > Preferences in the menu options, and then select the "Code rewrite" column
2, choose any of the following:
• Fixed illegal nested or closed tags
• Remove redundant end tags
3. Perform one of the following:
• Delete one or more of the list of file extensions from "Never rewrite code: in Files with extensions."
• Cancels the "Never rewrite code: in Files with extensions" option. Note that this can cause Dreamweaver to overwrite HTML code in any type of file.

Add Dreamweaver file types that prohibit overwriting:

1, select the Edit > Preferences in the menu options, and then select the "Code rewrite" column
2, choose any of the following:
• Fixed illegal nested or closed tags
• Remove redundant end tags
3, confirm "never rewrite code: in file with Extension" Item is selected, add a new file name extension to the list of text boxes.

If the new file type does not appear in the pop-up menu of the File > Open dialog box, you may need to add it to the Configuration/extensions.txt folder. For more information, see Changing the default file type.

Turn off the encoding options for Dreamweaver:

1, select the Edit > Preferences in the menu options, and then select the "Code rewrite" column
2. Cancel any of the two "special character encoding" options.

For additional information about the code rewrite parameter selection, see Using Dreamweaver.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.