Language Enhancements in ColdFusion Splendor

Download the public beta of ColdFusion Splendor from here

Various
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. 

Script
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.

  <cfscript>
   cfpdf (action=”getInfo”,  name=”pdfVar”,  source=”CF10MigrationGuide.pdf”);
  </cfscript>  

Note: The tag attributes should be enclosed within the parenthesis and must be comma-separated.

Case 2: Tags with child tags/body.

  <cfscript>
    cfform (name='myForm', acton='')
    {
         cfgrid (name="myGrid", query='empQuery')
        {
             cfgridcolumn (name='firstName', id='firstName', type='string');
             cfgridcolumn (name='lastName', id='LastName', type='string');
        }  
    }
  </cfscript>  

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:

  1. cfmodule based custom tags (supported in Splendor)
  2. cfm file based custom tags (supported in Splendor)
  3. Prefix based custom tags (not supported)
    // Tag based syntax
    <cf_happybirthday name="John" birthDate="December 5, 1987">
    
     //Script based syntax.
     <cfscript>     
         cf_happybirthday(name="John", birthDate="December 5, 1987");
     </cfscript>  

Stay tuned for more on the language enhancements. Please refer to the ColdFusion Splender public beta documentation for more details.

12 thoughts on “Language Enhancements in ColdFusion Splendor

  1. Any reason why all the script functions still have CF at the beginning when previous functions did not? Seems random to have half the functions with cf and half without. For example, cfproperty is just property, etc.

  2. @Tom,

    Yes, the old CFC funtions (Mail, Query, etc) will still be available for backwards compatibility.

    @Justin,

    Wouldn’t that be nice. I haven’t tested, but I wonder if the cfimport syntax is supported?

    @Scott,

    Yes, this is a nice start, but a language overhaul is still necessary. Guess we’ll have to see what CF 12 brings…

  3. @Scott,
    This approach has been taken based on the feedback we received on prerelease forum. In the argument given, the CF prefix helps it to look different from regular functions and hence can be easily differentiated. We thought of changing the old syntax too but left it as it is to maintain the backward compatibility. But going forward, we would encourage people to use latest syntax.

  4. Hi CFTeam,

    any reason why cfloop(from=”1″, to=”10″, index=”i”) {} and cfloop(list=”a,b,c” index=”lst”) {} do not work? It is a little weird that these basic loop types are not working properly.

    Steph

  5. “Yes, the old CFC funtions (Mail, Query, etc) will still be available for backwards compatibility.”
    So they’re depreciated then ? Or are there really going to be two parallel and incompatible script-based ways to do common tasks like email and SQL ?

  6. I have install cf10 developer edition in my xampp but after that Apache is compulsorily shutdown it is refuse to start .help me to over come this

  7. I’ve been looking at a migration from CF9 to CF11. It seems that CF11 denies using to insert code from one file into another if the file being inserted isn’t a CFML (.cfm) file. The system I’m migrating uses to insert .cfx files. Rewriting the code would be onerous. Anybody have ideas on how we can move to CF11 without a rewrite?

Leave a Reply

Your email address will not be published. Required fields are marked *