ColdFusion Markup Language: Difference between revisions
Masondixon (talk | contribs) the history section on this page is a joke. |
|||
Line 40: | Line 40: | ||
== History == |
== History == |
||
The program was originally made by Allaire systems, based in Cambridge, Mass. The server-side technology was bought by Macromedia and became Macromedia Cold Fusion. |
|||
On June 18 2009, [[Adobe Systems|Adobe]] announced at the [[CFUnited]] conference that it had formed a [http://www.opencfml.org/ CFML Advisory Committee]<ref>http://corfield.org/entry/CFML_Advisory_Committee</ref> that would be responsible for guiding and reviewing changes to the CFML language. |
On June 18 2009, [[Adobe Systems|Adobe]] announced at the [[CFUnited]] conference that it had formed a [http://www.opencfml.org/ CFML Advisory Committee]<ref>http://corfield.org/entry/CFML_Advisory_Committee</ref> that would be responsible for guiding and reviewing changes to the CFML language. |
Revision as of 04:58, 23 March 2010
This ColdFusion Markup Language needs attention from an expert in Computing. Please add a reason or a talk parameter to this template to explain the issue with the ColdFusion Markup Language.(November 2008) |
It has been suggested that ColdFusion#Features be merged into this article. (Discuss) Proposed since July 2008. |
Paradigm | imperative, object-oriented |
---|---|
Designed by | Jeremy Allaire |
Developer | Adobe Systems, Railo, New Atlanta |
First appeared | 1995 |
OS | Windows, Linux, UNIX, Macintosh |
License | Depends on the implementation |
Website | CFML Advisory Committee, Adobe ColdFusion, Railo, BlueDragon |
Major implementations | |
Adobe ColdFusion, Railo, BlueDragon |
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. The CFML language is guided by the CFML Advisory Committee.
Synopsis
CFML generally augments standard HTML files with database commands, conditional operators, high-level formatting functions, and other elements to produce web applications.[1]
The pages in a ColdFusion application include the server-side CFML tags in addition to HTML tags. When a web browser requests a page in a ColdFusion application, it is automatically pre-processed by the ColdFusion Application Server.[2]
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.
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.[3]
History
The program was originally made by Allaire systems, based in Cambridge, Mass. The server-side technology was bought by Macromedia and became Macromedia Cold Fusion.
On June 18 2009, Adobe announced at the CFUnited conference that it had formed a CFML Advisory Committee[4] that would be responsible for guiding and reviewing changes to the CFML language.
Syntax
CFML tags have a similar format to HTML tags. They are enclosed in angle brackets (< and >) and generally have zero or more named attributes, though some tags (e.g. cfset, cfif) 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:
<cfoutput>
#value# Bob!
</cfoutput>
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.
<cfset value = "Hello">
<cfset value = "Hello" />
Sometimes, although the tag can have a body, you find that you do not need to put anything in it because the attributes specify all the required information. In these cases (as with all HTML), you can choose to omit the end tag (and hence, the body) and just put a forward slash character before the closing (>) character, as in the following example:[5]
<cfexecute name="C:\winNT\System32\netstat.exe" arguments="-e" outputfile="C:\Temp\out.txt" timeout="1" />
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 used 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.[6]
- 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 (cfimage, cfregistry etc)
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:
<cfset caller.sum = attributes.first + attributes.second / >
Assuming the template and tag are in the same directory, the tag can be invoked thus:
<cf_sum first="1" second="2">
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 <cfimport> tag.
Functions
ColdFusion Markup Language includes a set of functions that you use to perform logical and arithmetic operations and manipulate data.
function | code |
---|---|
Array | [7] (ArraySort, ArrayAppend, ArrayDeleteAt...) |
Conversion | [8] (URLEncodedFormat, ToString...) |
Date and time | [9] (LsTimeFormat, DateAdd, DateDiff...) |
Decision | [10] (IsDefined, IIF...) |
Display and formatting | [11] (CJustify, NumberFormat...) |
Dynamic evaluation | [12] (DE, Evaluate...) |
Extensibility | [13] (CreateObject, ToScript...) |
Image | [14] (ImageRotate, ImageAddBorder...) |
International functions | [15] (SetLocale, GetTimeZoneInfo...) |
List | [16] (FindOneOf, ListSetAt...) |
Mathematical | [17] (Randomize, Sqr...) |
Other functions | [18] (WriteOutput, GetBaseTemplatePath...) |
Query | [19] (QueryAddColumn, QuerySetCell...) |
Security | [20] (Encrypt, Decrypt...) |
String | [21] (Reverse, HTMLCodeFormat...) |
Structure | [22] (StructKeyExists, StructDelete...) |
System | [23] (GetTickCount, GetTempFile...) |
XML | [24] (XMLParse, GetSOAPResponse...) |
ColdFusion Components (CFCs)
CFCs 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.
- <cfcomponent>: Defines a CFC
- <cffunction>: Defines the functions (methods) within a CFC
- <cfargument>: Defines the arguments (parameters) that a function accepts
- <cfreturn>: 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 <cfinvoke> tag to call your component methods from a.cfm file. <cfinvoke> 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 <cfinvoke> tag.[25]
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.
<!--- temperature.cfc --->
<cfcomponent>
<cffunction name="FtoC" access="public" returntype="numeric">
<cfargument name="fahrenheit" required="yes" type="numeric" />
<cfset answer= (fahrenheit - 32)*100/180 />
<cfreturn answer />
</cffunction>
</cfcomponent>
<!--- test.cfm --->
<cfset fDegrees = 212 />
<cfinvoke component="temperature" method="FtoC" returnvariable="result">
<cfinvokeargument name="fahrenheit" value="#fDegrees#" />
</cfinvoke>
<cfoutput>#fDegrees#°F = #result#°C</cfoutput> <br />
References
- ^ ColdFusion Markup Language[1]
- ^ Michael Smith. "What is ColdFusion?" [2]
- ^ Tags. [3]
- ^ http://corfield.org/entry/CFML_Advisory_Committee
- ^ Tag syntax[4]
- ^ Tags by function. [5]
- ^ Array functions[6]
- ^ Conversion functions[7]
- ^ Date and time functions[8]
- ^ Decision functions[9]
- ^ Display and formmatting functions[10]
- ^ Dynamic evaluation functions[11]
- ^ Extensibility [12]
- ^ Image functions[13]
- ^ International functions[14]
- ^ List functions[15]
- ^ Mathematical functions[16]
- ^ Other functions[17]
- ^ Query functions[18]
- ^ Security functions[19]
- ^ String functions[20]
- ^ Structure functions[21]
- ^ System functions[22]
- ^ XML functions[23]
- ^ Ben Forta, "Using ColdFusion components"[24]
External links
- CFQuickDocs—ColdFusion tags and functions reference
- Adobe Dreamweaver CS4 - CFML IDE (Integrated Development Environment)
- EasyCFM—ColdFusion Reference, Tutorials and Community Outreach site. Learn ColdFusion!
- LearnCF - Learn ColdFusion with ColdFusion tutorials. Every tutorial has a working demo, code view and code download.
- Free ColdFusion Hosting—the perfect way to learn ColdFusion, get free coldfusion
- ColdFusion.TV— Free ColdFusion Video Tutorials!