Proposal: CFSaveContent "file" attribute

When it comes to CFSaveContent, I have a common use case where I do something like this:

<cfsavecontent variable="htmlContent">
    <cfinclude template="./cf-logic.cfm" />
</cfsavecontent>

<cfset fileWrite( htmlContent, "./generated.html" ) />

It would be nice if the CFSaveContent tag had a file option, so I could skip that last step:

<cfsavecontent file="./generated.html">
    <cfinclude template="./cf-logic.cfm" />
</cfsavecontent>

Or, I mean, the best thing would also be if there as just some sort of renderToFile() function:

renderToFile( "./cf-logic.cfm", "./generated.html" );

Anyway, just a random thought.

13 Likes

I like it, how do we make you more random?

4 Likes

Ha ha :smiley:

1 Like

A few years later, I decided to implement this myself as a ColdFusion custom tag, CF_SaveFile. I love how flexible ColdFusion is - just bonkers!

8 Likes