ColdFusion Markup Language

From Wikipedia, the free encyclopedia

Adobe Systems Cold Fusion Markup Language (CFML)
Paradigm imperative, object-oriented
Appeared in 1995
Designed by Jeremy Allaire
Developer Adobe
Latest release 8/ July 30, 2007
Major implementations Adobe ColdFusion
OS Windows, Linux, UNIX, Macintosh
License Proprietary
Website Adobe ColdFusion

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

Contents

[edit] Syntax

Tags which are included in the core runtime are always prefixed with a cf followed by unique identifier, starting with a letter. Custom tags written in CFML may be prefixed with cf_, although there are other ways to invoke them.

Procedural style functions are available throughout a CFScript.

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 relies heavily on maps, where the keys are always strings and the values are not type specific. Values are often accessed 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.

Recent CFML implementations include support for objects, known as components. Component definitions reside in a file, and are surrounded by cfcomponent tags.

Message passing to components is also done via dot notation, similar to other object-oriented languages such as Java. If omitting the open and close brackets of a method invocation, ColdFusion will treat the function as the value object a map. This allows methods to be treated as first-class objects.

CFML is not XML and 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.

CFML's name is misleading; it is not a markup language.

[edit] Constants

Constants are the variables, whose values can not be changed during the the program execution. CFML does not allow to define constants in the program.

[edit] Flow Control Tags

There are two kinds of Flow Control Tags are there. 1. Conditional 2. Looping.

Conditional Tags: There are three types of conditional tags available in ColdFusion.

          A. Using <CFIF>, <CFELSEIF> and <CFELSE>.
          B. Using <CFSWITCH>, <CFCASE> and <CFDEAFULTCASE>.
          C. IIF( ) Function.

Looping Tags: <cfloop> tag is used to implement looping in ColdFusion. There are two kings of looping is available. One is conditional and another one is Index based looping.


[edit] Custom tags

CFML allows language extensions in the form of custom tags. Custom tags are normal files which are intended 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 accessible via the caller struct. For example, if writing an add tag which takes two attributes and adds them together, the sum.cfm page would look like this:

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

The tag can be invoked thus:

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

assuming the template and tag are in the same directory.


[edit] External links