ColdFusion Markup Language
ColdFusion Markup Language, more commonly known as CFML, is a scripting language for web development that runs on the JVM, the.NET framework, and Google App Engine. Multiple commercial and open source implementations of CFML engines are available, including Adobe ColdFusion, Lucee, New Atlanta BlueDragon, Railo, and Open BlueDragon as well as other CFML server engines.
Synopsis
In its simplest form, like many other web scripting languages, CFML augments standard HTML files with database commands, conditional operators, high-level formatting functions, and other elements to produce web applications. CFML also includes numerous other constructs including ColdFusion Components, CFML's version of objects, that allow for separation of business logic from presentation.CFML can be written using either tags or CFScript, which resembles JavaScript .
The pages in a CFML application include the server-side CFML tags and functions in addition to HTML tags, and modern CFML applications also tend to have CFCs that are accessed by the CFML pages for executing business logic. When a web browser requests a page in a ColdFusion application, it is automatically pre-processed by the ColdFusion application server.
CFML can also be used to generate other languages, aside from HTML, such as XML, JavaScript, CSS, and so on.
Despite the name, CFML is not a markup language. It is also not SGML, since certain core CFML features prevent it from complying.
The CFML engine is configured in such a way that certain file extensions on the server are handed off to the CFML engine for processing. In the case of the Java-based engines this is accomplished via Java servlets. The CFML engine only processes CFML tags and functions; it returns text outside of CFML tags and functions to the web server unchanged.
History
Named Cold Fusion at the outset, the software was created in 1995 by the Allaire Corporation, originally located in Minnesota. It later moved to Cambridge, Massachusetts and then finally to Newton, Massachusetts before being acquired by Macromedia in 2001. Allaire Cold Fusion thus became Macromedia Cold Fusion. At the release of version 4, the space in the name was removed to become ColdFusion. Adobe acquired Macromedia in 2005 and is still actively developing ColdFusion.In 1998 Alan Williamson and his Scottish company, "n-ary", began creating a templating engine for Java to simplify common programming tasks. Williamson was using curly-brace notation instead of tags, but when he saw an example of CFML and how it was solving similar problems using a tag syntax, he started developing what would eventually become BlueDragon, which was the first Java implementation of the CFML language. New Atlanta licensed BlueDragon around 2001 and made it available as a commercial product, eventually creating a.NET implementation of CFML. Open BlueDragon is a fork of the commercial BlueDragon product and was first released in 2008.
The Railo CFML engine began as a student project in 2002 and was first launched as a commercial project in 2005. Railo announced they were making the engine open source in 2008, and the first open source version was released in 2009.
On June 18, 2009, Adobe announced at the CFUnited conference that it had formed a CFML Advisory Committee that would be responsible for guiding and reviewing changes to the CFML language. This effort was disbanded in 2010. The Google Group CFML Conventional Wisdom was created as a forum for open, public discussions about language and engine features; its use has dwindled since 2011.
In 2012, the OpenCFML Foundation was launched. Its function is to push open-source CFML applications and platforms.
Former Railo lead developer Michael Offner launched Lucee, a fork of the Railo, in London on January 29, 2015. Backed by community supporters and members of the Lucee Association, the goal of the project is to provide the functionality of CFML using fewer resources, giving better performance and to move CFML past its roots and into a modern and dynamic Web programming platform.
Syntax
CFML tags have a similar format to HTML tags. They are enclosed in angle brackets and generally have zero or more named attributes, though some tags contain an expression rather than attributes. Many CFML 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 in the form of tag attributes, as in the example below. If it is legal for tags not to have a body, it is syntactically acceptable to leave them unclosed as in the first example, though many CFML developers choose to self-close tags as in the second example to make the code more legible.
Even if the tag can have a body, including a body may not be necessary in some instances because the attributes specify all the required information. In these cases, as with the second example above, the end tag may be omitted and the tag may be self-closing as in the following example:
Various tags offer the ability to type-check input parameters if the programmer declares their type specifically. This functionality is used with cfqueryparam to secure web applications and databases from hackers and malicious web requests such as SQL injection.
Built-in tags
Nearly 100 tags and many more functions make up the heart of the CFML language. The following lists CFML tags by their function or purpose.- Application framework
- Communications
- Control
- *Flow-control
- *Database manipulation
- *Exception handling
- Data output
- Debugging
- Display management
- Extensibility
- File management
- form
- Internet protocol
- Page processing
- Security
- Variable manipulation
- Other tags
Custom tags
If a template is invoked as a custom tag, the attributes used to invoke that tag are available within the tag in an attributes scope and the variables for the calling page are accessible via the caller scope.
For example, if writing a custom tag to perform addition, taking two attributes and adding them together, the tag would be an addition.cfm file which could look like this:
Assuming the tag is in the same directory as the file, it can be invoked thus:
CFX tags are custom tags which are developed using Java or C++, and are prefixed with cfx_ just like cf_. Java and C++ tags are added to the CFML runtime environment using the CFML engine's administrator or by editing configuration files.
On some CFML engines JSP tags can also be included in CFML pages using the
Functions
ColdFusion Markup Language includes a set of functions that you use to perform logical and arithmetic operations and manipulate data.function | reference | code |
Array | ||
Conversion | ||
Date and time | ||
Decision | ||
Display and formatting | ||
Dynamic evaluation | ||
Extensibility | ||
Image | ||
International functions | ||
List | ||
Mathematical | ||
Other functions | ||
Query | ||
Security | ||
String | ||
Structure | ||
System | ||
XML |
ColdFusion Components (CFCs)
CFCs provide some of the typical features and functionality that are provided by object-oriented languages.To create a CFC:
CFCs are plain CFML. Within a CFC any CFML tag, function, custom tag, other components, etc. may be used.
CFCs can be used in various ways. If a method contained in a CFC simply needs to be invoked, the
CFCs are created using four tags, saved as.CFC files, and invoked using the
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.
CFCs may also be instantiated as objects. Assuming a CFC file called Person.cfc, an instance of this CFC would be instantiated as follows:
CFCs also form the basis of the ability to create web services in CFML. A CFC is created in the usual way, and the attribute access="remote" added to any function within the CFC will make that function available to be called as a SOAP-based web service. The CFML engine auto-generates a WSDL and creates all the necessary stubs for the web service to function.