Utility Function: RenderTemplate()

This function is half-way to being a really nice function. I just wish that I could pass in arguments, or a structure to use as the variables available in the rendered template. I'd love to have that isolation...


<cffunction name="RenderTemplate" access="public" output="false" returnType="string">
    <cfargument name="path" type="string" required="false" />
    
    <cfset var local = StructNew() />
    
    <cfsavecontent variable="local.returnValue">
        <cfinclude template="#arguments.path#" />
    </cfsavecontent>
    
    <cfreturn local.returnValue />
</cffunction>

 

Related Blog Entries

Comments are not allowed for this entry.
Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me on LinkedIn.