Domanda

My question could sound like weird, I want to include a template in a CFML script but not as a different file but a string/text/base64 data in the same file. Is that possible or there is a way in CFML? I can do that in PHP with files as base64 data even images base64 encoded. I thought about something like (not working, of course):

<cfset myinclude = ToString(toBinary('PGNmb3V0cHV0PkNvbGRGdXNpb24gMTA8L2Nmb3V0cHV0Pg=='))>

<cfif listfirst(server.coldfusion.productversion) gte 8>
        <cfinclude template = "#myinclude#">
</cfif>

Why would I do that? To overcome errors between different functions with same name in different CF versions (6, 7, 8, 9, 20) but same names, for portability.

È stato utile?

Soluzione

Found a way to make it work, not really what I wanted but works:

<cfset myinclude = "PGNmb3V0cHV0PkNvbGRGdXNpb24gMTA8L2Nmb3V0cHV0Pg==">

<cfif listfirst(server.coldfusion.productversion) gte 8>
        <cfset myincludesource = "A-#CreateUUID()#">
        <cfset fileWrite(expandPath("#myincludesource#.cfm"), ToString(toBinary(myinclude)))>
        <cfinclude template = "#myincludesource#.cfm">
        <cfset fileDelete(expandPath("#myincludesource#.cfm"))>
</cfif>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top