
18
DEVELOPING
COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Las
t
upda
te
d 8/5/2010
Note:
You cannot embed comments inside a tag name or function name, such as
<cf_My<!--- New --->CustomTag>
.
You also cannot embed comments inside strings, as in the following example:
IsDefined("My<!--- New ---
>Variable")
.
Tags
ColdFusion
tags
tell the ColdFusion server that it must process information. The ColdFusion server only processes tag
contents; it returns text outside ColdFusion to the web server unchanged. ColdFusion provides a wide variety of built-
in tags and lets you create custom tags.
Tag syntax
ColdFusion tags have the same format as HTML tags. They are enclosed in angle brackets (< and >) and can have zero
or more named attributes. Many ColdFusion tags have bodies; that is, they have beginning and end tags with text for
processing between them. For example:
<cfoutput>
Hello #YourName#! <br>
</cfoutput>
Other tags, such as
cfset
and
cfhttp
, never have bodies. All the required information goes between the beginning
(<) character and the ending (>) character, as in the following example:
<cfset YourName="Bob">
Note:
The
cfset
tag differs from other tags in that it does not have a body or arguments. Instead, the tag encloses an
assignment statement that assigns a value to a variable. The
cfset
tag can also call a function without assigning a value
to a result variable.
Sometimes, although the tag can have a body, it is unnecessary because the attributes specify all the required
information. You can omit the end tag and place a forward slash character before the closing (>) character, as in the
following example:
<cfprocessingdirective pageencoding="euc-jp" />
In most cases, you specify tag attributes directly in the tag using the format
attributeName
="
attributeValue
"
, as the
preceding example shows. However, as an alternative, you can place all the attributes in a structure and specify the
structure in a single
attributeCollection
attribute, using the following format:
<tagname attributeCollection="#structureName#">
When you use this format for all built-in ColdFusion tags except
cfmodule
, the tag must have only the
attributeCollection
attribute. This format is useful when you use dynamic arguments, where the number and
values of the arguments to a tag can vary based on processing results. The following example shows this usage:
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...