ColdFusion Markup Language

From Wikipedia, the free encyclopedia

ColdFusion Markup Language, more commonly known as CFML, is the scripting language used by Adobe ColdFusion and several alternative server environments, including BlueDragon, Coral Web Builder, IgniteFusion, Railo. It is similar to HTML in that it uses tags, need not be well-formed, and including a built-in script tag to allow inline scripting within markup.

[edit] Syntax

Tags which are included in the core runtime are always prefixed with a cf.

Procedural style functions are available throughout a CFML script.

CFML is generally considered a dynamic language. However, various tags offer the ability to type-check input parameters (eg: cffunction, cfparam, cfqueryparam) if the programmer declares their type specifically. It is debated whether this is good practice, as failure occurs at runtime regardless of whether type checking is used or not.

CFML is case insensitive.

CFML relies heavily on maps, where the keys are always strings and the values are not type specific. Values are often access using dot notation, but -- depending on the CFML implementation -- can be accessed via procedural functions, or can be treated as objects where instance get methods are invoked.

CFML need not be well-formed. If it is legal for tags not to have a body, it is syntactically acceptable to leave them unclosed. For example:

<cfset value = "hello">

The self-closing variant

<cfset value = "hello"/>

is also legal. Which style should be used is an often debated issue.

[edit] Custom Tags

CFML allows language extentions in the form of custom tags. Custom tags are normal files which are intentended to be invoked as tags, although it is possible to treat a template as both a custom tag and a regular template.

If a template is invoked as a custom tag, the attributes used to invoke that tag are available in a special structure attributes and the variables on the calling page are accessable via the caller' struct. For example, if writing an add tag which takes two attributes and adds them together, the add.cfm page would look like this:

<cfset caller.sum = attributes.first + attributes.second />

The tag can be invoked thusly:

<cf_sum first="1" second="2">

assuming the template and tag are in the same directory.

[edit] See also

In other languages