Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created March 25, 2014 00:56
Show Gist options
  • Save bennadel/9753168 to your computer and use it in GitHub Desktop.
Save bennadel/9753168 to your computer and use it in GitHub Desktop.
ColdFusion Functions Declared Inside CFScript Have Output
<cfcomponent
output="false"
hint="I define the application event handlers and page request settings.">
<cfscript>
THIS.Name = "CFScriptTesting";
THIS.ApplicationTimeout = CreateTimeSpan( 0, 0, 5, 0 );
// Execute pre-page logic.
function OnRequestStart( Page ){
WriteOutput( "OnRequestStart:" );
// Include the user-selected page.
VARIABLES.Include( ARGUMENTS.Page );
}
// Executes the target template.
function OnRequest( Page ){
WriteOutput( "OnRequest:" );
// Include the user-selected page.
VARIABLES.Include( ARGUMENTS.Page );
}
</cfscript>
<cffunction
name="Include"
access="private"
returntype="void"
hint="I include templates inside of CFScript.">
<!--- Define arguments. --->
<cfargument
name="Template"
type="string"
required="true"
hint="I am the template to be included."
/>
<!--- Include template. --->
<cfinclude template="#ARGUMENTS.Template#" />
<!--- Return out. --->
<cfreturn />
</cffunction>
</cfcomponent>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment