Have you ever wanted to work with CFML as a language from within CFML? For example, store a snippet of CFML code for processing at a later date? Possibly storing blocks of CFML code inside a database.
This power allows you to write plugin's for your applications without having to resort to ugly file writing and then processing. But even the file writing technique has its problems - have you ever tried to just store a block of CFML code as text without the engine getting in the way and trying to be helpful and execute it for you?
OpenBD gives you a couple of very powerful additions that lets you build completely dynamic and customizable code that can be manipulated and executed inline or at a later date.
<nocfml> ... </nocfml>
Inspired from the NOWIKI tag from MediaWiki, that lets you quickly write up blocks of text without being processed by the wiki engine, OpenBD introduces the NOCFML tag.
The <nocfml> tag lets you capture complete blocks of CFML code without first being processed by the underlying CFML engine. Simply wrap your CFML code in this tag and the OpenBD engine will ignore all CFML tags and directives. CFML tags will be treated as if they are normal HTML tags and be sent straight to the requester.
<nocfml> <cfset myvar = "this will not be executed"> <cfabort> </nocfml>
If you were to run this code and view it from a browser, you would see the actual CFML tags displayed in the source of the HTML page. These tags would not be executed. So the CFABORT tag wouldn't have any effect here as it would be simply treated as a block of text. To capture the CFML code to a variable for processing or storage, then you would simply wrap it in a CFSAVECONTENT tag.
<cfsavecontent variable="captureCfml"> <nocfml> <cfset myvar = "this will not be executed"> <cfabort> </nocfml> </cfsavecontent> <cfoutput>#XmlFormat(captureCfml)#</cfoutput>
Rendering Dynamic CFML code
Now that you have a block of CFML code stored as a string, how can you now render the code, as if it appeared in the page?
<cfsavecontent variable="captureCfml"> <nocfml> <cfset myvar = "this will not be executed"> </nocfml> </cfsavecontent> <cfset render(captureCfml)>
This is a very powerful function that lets you build very complex applications from snippets of dynamically generated code or previously stored CFML snippets.