Customizing Dreamweaver > Customizing the interpretation of third-party tags |
Customizing the interpretation of third-party tags
Server-side processing technologies such as ASP, ColdFusion, JSP, and PHP use special non-HTML code in HTML files; servers create and serve HTML content based on that code. When Dreamweaver encounters non-HTML tags, it compares them with information in its third-party tag files, which define how Dreamweaver reads and displays non-HTML tags.
For example, ASP files containin addition to regular HTMLASP code for the server to interpret. ASP code looks something like a tag, but is marked by a pair of delimiters: it begins with <%
and ends with %>
. Dreamweaver's Configuration/ThirdPartyTags folder contains a file named ASP.xml, which describes the format of ASP code and defines how Dreamweaver displays that code. Because of the way ASP code is specified in ASP.xml, Dreamweaver doesn't try to interpret anything between the delimiters; instead, in the Design view of the Document window, it simply displays an icon indicating ASP code.
You can define your own tags and create tag database files that define how Dreamweaver reads and displays your tags. Creating tag database files is particularly useful if you're using a server-side markup system other than ASP, JSP, ColdFusion, or PHP; create a new tag database file for each such markup system, to tell Dreamweaver how to display the tags. (There is no separate JSP tag database file; JSP code uses the same delimiters as ASP code, so Dreamweaver uses the ASP tag database file for JSP.)
Note: This section explains how to define the way Dreamweaver displays a custom tag, but doesn't describe how to provide a way to edit the content or properties of a custom tag. For information on how to create a Property inspector to inspect and change the properties of a custom tag, see "Property Inspectors" in Extending Dreamweaver.
Each tag database file defines the name, type, content model, rendering scheme, and icon for one or more custom tags. You can create any number of tag database files, but all of them must reside in the Configuration/ThirdPartyTags folder to be read and processed by Dreamweaver. Tag database files have the file extension .xml.
Tip: If you are working on several different unrelated sites at once (for example, as a freelance developer), you can put all the tag specifications for a particular site in one file. Then simply include that tag database file with the custom icons and Property inspectors that you hand over to the people who will maintain the site.
You define a tag specification with an XML tag called tagspec
; for example, the following code describes the specification for a tag named happy
:
<tagspec tag_name="happy" tag_type="nonempty" render_contents="false" content_model="marker_model" icon="happy.gif" icon_width="18" icon_height="18"></tagspec>
You can define two different kinds of tags using tagspec
: normal HTML-style tags and string-delimited tags. String-delimited tags start with one string and end with another string; they're like empty HTML tags (such as img
) in that they don't surround content and don't have closing tags. The happy
tag shown above is a normal HTML-style tag; it starts with an opening <happy>
tag, contains data between opening and closing tags, and ends with a closing </happy>
tag. (If the tag were a string-delimited tag, the tag specification would include the start_string
and end_string
attributes.) An ASP tag is a string-delimited tag; it starts with the string <%
and ends with the string %>
, and it has no closing tag.
The following information describes the attributes and valid values for the tagspec
tag. Attributes marked with an asterisk (*) are ignored by string-delimited tags.
Description
Provides information about a third-party tag.
Attributes
tag_name
, tag_type
, render_contents
, content_model
, start_string
, end_string
, detect_in_attribute
, parse_attributes
, icon
, icon_width
, icon_height
tag_name
The name of the custom tag. (For string-delimited tags, tag_name
is used only to determine whether a given Property inspector can be used for the tag. If the first line of the Property inspector contains this tag name with an asterisk on each side, then the inspector can be used for tags of this type. For example, the tag name for ASP code is ASP
; Property inspectors that can examine ASP code should have *ASP*
on the first line. For information on the Property inspector API, see "Property Inspectors" in Extending Dreamweaver.)
tag_type
* Determines whether the tag is empty (as with img
), or whether it contains anything between its opening and closing tags (as with code
). This attribute is required for normal (non-string-delimited) tags. It's ignored for string-delimited tags, since they're always empty. Valid values are "empty"
and "nonempty"
.
render_contents
* Determines whether the contents of the tag should appear in the Document window's Design view, or whether the icon appears instead. This attribute is required for nonempty tags, and ignored for empty tags. (Empty tags have no content.) This attribute applies only to tags that appear outside of attributes; the contents of tags that appear inside the values of attributes of other tags are not rendered. Valid values are "true"
or "false"
.
content_model
* Describes what kinds of content the tag can contain and where in an HTML file the tag can appear. Valid values are "block_model"
, "head_model"
, "marker_model"
, and "script_model"
:
block_model Specifies that the tag can contain block-level elements such as div and p , and that the tag can appear only in the body section or inside other body-content tags such as div , layer , or td . |
|
head_model Specifies that the tag can contain text content, and that it can appear only in the head section. |
|
marker_model Specifies that the tag can contain any valid HTML code, and that it can appear anywhere in an HTML file. The HTML validator in Dreamweaver ignores tags that are specified as marker_model . However, the validator doesn't ignore the contents of such a tag; so even though the tag itself can appear anywhere, the contents of the tag may result in invalid HTML in certain places. For example, plain text can't appear (outside a valid head element) in the head section of a document, so you can't place a marker_model tag that contains plain text in the head section. (To place a custom tag containing plain text in the head section, specify the tag's content model as head_model instead of marker_model .) Use marker_model for tags that should be displayed inline (inside a block-level element such as p or div for example, inside a paragraph). If the tag should be displayed as a paragraph of its own, with line breaks before and after it, don't use this model. |
|
script_model Allows the tag to exist anywhere between the opening and closing HTML tags of a document. When Dreamweaver encounters a tag with this model, it ignores all of the tag's content. Used for third-party markup (like certain ColdFusion tags) that Dreamweaver shouldn't parse. |
start_string
Specifies a delimiter that marks the beginning of a string-delimited tag. String-delimited tags can appear anywhere in the document where a comment can appear. Dreamweaver does not parse tags or decode entities or URLs between start_string
and end_string
. This attribute is required if end_string
is specified.
end_string
Specifies a delimiter that marks the end of a string-delimited tag. This attribute is required if start_string
is specified.
detect_in_attribute
Indicates whether to ignore everything between start_string
and end_string
(or between opening and closing tags if those strings aren't defined) even when those strings appear inside attribute names or values. You should generally set this to "true"
for string-delimited tags; the default is "false"
. For example, ASP tags sometimes appear inside attribute values, and sometimes contain quotation marks ("); because the ASP tag specification specifies detect_in_attribute="true"
, Dreamweaver ignores the ASP tags, including the internal quotation marks, when they appear inside attribute values.
parse_attributes
* Indicates whether to parse the attributes of the tag. If this is set to "true"
(the default), Dreamweaver parses the attributes; if it's set to "false"
, Dreamweaver ignores everything until the next closing angle bracket that appears outside quotation marks. For example, this attribute should be set to "false"
for a tag like cfif
(as in <cfif a is 1>
, which Dreamweaver would be unable to parse as a set of attribute name/value pairs).
icon
Specifies the path and file name of the icon associated with the tag. This attribute is required for empty tags, and for nonempty tags whose contents are not displayed in the Document window's Design view.
icon_width
Specifies the width of the icon in pixels.
icon_height
Specifies the height of the icon in pixels
Contents
None (empty tag).
Container
None.
Example
<tagspec tag_name="happy" tag_type="nonempty" render_contents="false" content_model="marker_model" icon="happy.gif" icon_width="18" icon_height="18"></tagspec>