ColdFusion Markup Language

ColdFusion Markup Language

ColdFusion Markup Language, more commonly known as CFML, is the scripting language used by Adobe ColdFusion, BlueDragon and Railo, as well as other CFML server engines.

CFML is a tag-based versatile scripting language that is self-contained and easy-to-learn. It promotes rapid web application development. ColdFusion code is short and concise. It is easy to understand exactly what the code does, even without programming knowledge.

CFML enhances standard HTML files with database commands, conditional operators, high-level formatting functions, and other elements to rapidly produce easy-to-maintain web applications.

The pages in a ColdFusion application include the server-side CFML tags in addition to HTML (XHTML) tags. When a browser requests a page in a ColdFusion application, it is automatically pre-processed by the ColdFusion Application Server.

ColdFusion tags tell the ColdFusion server that it must process the tagged information. The ColdFusion server only processes ColdFusion tag contents; it returns text outside of ColdFusion tags to the web server unchanged.

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 to be processed between them. For example:
  #value# Bob!
Other tags, such as cfset and cfftp, never have bodies; all the required information goes between the beginning (<) character and the ending (>) character, as in the example below. If it is legal for tags not to have a body, it is syntactically acceptable to leave them unclosed. However, the self-closing variant is recommended as it complies with XHTML standards. Sometimes, although the tag can have a body, you do not need to put anything in it because the attributes specify all the required information. You can omit the end tag and put a forward slash character before the closing (>) character, as in the following example:

CFML is generally considered a dynamic language. Various tags offer the ability to type-check input parameters (e.g. cffunction, cfparam, cfqueryparam) if the programmer declares their type specifically. This functionality is put into very good use with cfqueryparam to secure web applications and databases from hackers and malicious web requests.

Built-in tags

Over 80 built-in tags make up the heart of ColdFusion. The following lists CFML tags by their function or purpose.

Custom tags

CFML allows language extensions in the form of custom tags. In other words, CFML allows tags that are not built-in ColdFusion 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. Custom tags written in CFML may be prefixed with cf_, although there are other ways to invoke them.

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:

Assuming the template and tag are in the same directory, the tag can be invoked thus:

CFX tags are custom tags which are developed using Java language or C++, and are prefixed with cfx_ just like cf_. Tags are added to the ColdFusion runtime environment using the ColdFusion administrator, where JAR or DLL files are registered as custom tags.

JSP tags can also be included in CFML pages using the tag.

Functions

ColdFusion Markup Language includes a set of functions that you use to perform logical and arithmetic operations and manipulate data.

  • Array functions (ArrayNew, ArraySort, ArrayPrepend, ArrayAppend, ArrayDeleteAt...)
  • Conversion functions (URLEncodedFormat, ToString...)
  • Date and time functions (LsDateFormat, LsTimeFormat, DateAdd, DateDiff...)
  • Decision functions (IsDefined, IIF...)
  • Display and formatting functions (CJustify, NumberFormat...)
  • Dynamic evaluation functions (DE, Evaluate...)
  • Extensibility functions (CreateObject, ToScript...)
  • Image functions (ImageRotate, ImageAddBorder...)
  • International functions (SetLocale, GetTimeZoneInfo...)
  • List functions (FindOneOf, ListSetAt...)
  • Mathematical functions (Randomize, Sqr...)
  • Other functions (WriteOutput, GetBaseTemplatePath...)
  • Query functions (QueryAddColumn, QuerySetCell...)
  • Security functions (Encrypt, Decrypt...)
  • String functions (Reverse, HTMLCodeFormat...)
  • Structure functions (StructKeyExists, StructDelete...)
  • System functions (GetTickCount, GetTempFile...)
  • XML functions (XMLParse, GetSOAPResponse...)

ColdFusion Components (CFCs)

CFCs provide the power of objects with the simplicity of CFML. They provide some (not all) of the typical features and functionality that are provided by object-oriented (OOP) languages. To create a CFC:
Create a file with a.CFC extension (this distinguishes CFCs from ColdFusion templates, which have a.CFM extension).
Use four tags to create the components, define their functions and arguments, and return a value.
: Defines a CFC
: Defines the functions (methods) within a CFC
: Defines the arguments (parameters) that a function accepts
: Returns a value or result from a function
CFCs are plain CFML. Within a CFC you can use any tag, function, custom tag, component, and more. After creating your CFC, save it with.cfc extension.

To use your CFC, use tag to call your component methods from a.cfm file. takes the name of the component (minus the.cfc extension) and the method to execute. To access any returned data, the RETURNVARIABLE attribute provides the name of a variable to contain whatever the function returns. CFCs are created using four tags, saved as.CFC files, and invoked using the tag.

In the example below, component temperature.cfc has a method FtoC which converts temperature from Fahrenheit to Celsius. The test.cfm template invokes the method and converts 212 degrees Fahrenheit and outputs the result.

 
   
   
   
 
 
#fDegrees#oF = #result#oC

References

External links

Search another word or see ColdFusion Markup Languageon Dictionary | Thesaurus |Spanish
Copyright © 2014 Dictionary.com, LLC. All rights reserved.
  • Please Login or Sign Up to use the Recent Searches feature
FAVORITES
RECENT

;