Download the public beta of ColdFusion Splendor from here
enhancements have been added to the core CFML language to provide a better
development experience. Script support for CF
tags and member functions for CF data structure were long pending feature requests and we are
happy to add these two along with a few more enhancements in ColdFusion Splendor (codename). The following list shows the enhancements made in the CFML language:
- Script support for tags
- Member functions for CF data type/data structure
- Improved JSON serialization
- Easy to use CF functions for Query tag
- Elvis operator (?:)
- Promoting built-in CF function to first class
- Miscellaneous new functions: QueryGetRow, ListEach and others.
We will be doing a series of blog posts on language enhancements and this post will only be on the Script support for tags.
support for tags
Traditionally, while coding in script syntax, you have to switch to tag-based syntax if you have to use CF tags. The reason being, the CF tags, barring
few, were not available in the script syntax. ColdFusion Splendor onwards, most of the ColdFusion tags are made available to be used in the CFScript block. Now, you can invoke most of the CF tags within the CFScript blocks. One more good thing about the current implementation is that it will automatically take care of any future tag being added to the CF language.
Case 1: Simple tag with no child/body.
cfpdf (action=”getInfo”, name=”pdfVar”, source=”CF10MigrationGuide.pdf”);
Note: The tag attributes should be enclosed within the parenthesis and must be comma-separated.
Case 2: Tags with child tags/body.
cfform (name='myForm', acton='')
cfgrid (name="myGrid", query='empQuery')
cfgridcolumn (name='firstName', id='firstName', type='string');
cfgridcolumn (name='lastName', id='LastName', type='string');
Note: The child tag (and the body in general) should be enclosed in curly brackets, as a function block.
Case 3: Custom tag
ColdFusion provides three different ways to write custom tags as shown in the following list:
- cfmodule based custom tags (supported in Splendor)
- cfm file based custom tags (supported in Splendor)
- Prefix based custom tags (not supported)
// Tag based syntax
<cf_happybirthday name="John" birthDate="December 5, 1987">
//Script based syntax.
cf_happybirthday(name="John", birthDate="December 5, 1987");
Stay tuned for more on the language enhancements. Please refer to the ColdFusion Splender public beta documentation for more details.