I found a non-eloquent work around for my problem. I wrote some regular expressions to search for occurences of
'#some variable#'
and to replace all such occurences with
'#DoubleUp(some variable)#'
So code like
<cfset p_lsSql = "INSERT INTO TEST (NAME,CITY,STREET) VALUES ('#FORM.NAME#','#FORM.CITY#','#FORM.STREET#')">
<cfinclude template="process_sql.cfm">
gets changed to
<cfset p_lsSql = "INSERT INTO TEST (NAME,CITY,STREET) VALUES ('#DoubleUp(FORM.NAME)#','#DoubleUp(FORM.CITY)#','#DoubleUp(FORM.STREET)#')">
<cfinclude template="process_sql.cfm">
I had hundreds and hundreds of places to do this and without the use of regular expressions I would have had a nightmare on my hand. With regular expressions it was trivial. For those interested my regular expressions were:
Find: '#([A-Z._a-z0-9]+[A-Z._a-z0-9]*)#'
Replace with:'#DoubleUp(\1)#'
and inside template="process_sql.cfm I have
<CFQUERY . . . >
#PreserveSingleQuotes(p_lsSql )#
</CFQUERY>
I then just wrote the cutom function DoubleUp:
<cffunction name="DoubleUp" output="no" access="public" returnType="string">
<cfargument name="lsVarIn" type="string" required="true"/>
<cfreturn Replace(lsVarIn,"'","''","ALL") />
</cffunction>
So far I haven't come across any problems with this approach and I have been able to have all my SQL pass through template. (I wanted to do this for my own reasons.)