Try this 
http://code.google.com/p/coldquery/source/browse/trunk/src/org/coldquery/UDFCreator.cfc
 It doesn't execute the code, but it creates a udf from a string.  Then you can 
call the udf.  The string can be cfml or script.

So an example using script would be:

<cfscript>
yourcfmlcode = {read your source from the db};
scriptfun = "<cffunction name='f' output='false'>";
scriptfun = scriptfun & "<cfset var out='' /><cfsavecontent variable='out'>";
scriptfun = scriptfun & yourcfmlcode;
scriptfun = scriptfun & "</cfsavecontent><cfreturn out /></cffunction>";

//Create a UDF from the string above
myudf = 
createObject("component","org.coldquery.UDFCreator").createudf(scriptfun);

</cfscript>
<cfoutput>#myUDF()#</cfoutput>


> Hi,
> 
> I'm not sure if this is possible or not. What I want to do is store 
> snippets of coldfusion code (for an email template) in a database. I 
> then want to take that database record, load it into a variable and 
> then have coldfusion process the variable as if it were code that was 
> written in a normal cfm template.
> 
> One way that I could do it is to write the code to a .cfm file (using 
> cffile) and then read that file back in via a cfinclude to be 
> processed as normal. However, I wish to avoid this solution if 
> possible.
> 
> An example:
> In the database, this is the code that has been stored as text:
> 
> 
> 
> <cfoutput>
> <p>Dear #buyerrecord.getfirstname()#,<p>
>               
> 
> <p>Your order has shipped. Your tracking number is #orderrecord.
> gettrackingnumber()#</p>
> 
> <p>Thanks,</p>
> <p>Your friendly and highly attentive and customer-focused Customer 
> Service Representative</p>
> 
> 
> 
> 
> This will then be read into a variable (perhaps named 
> emailtemplatecontent) which I then wish to execute within <cfmail> 
> tags.
> 
> For example:
> 
> <cfmail to"[EMAIL PROTECTED]".....>
> #emailtemplatecontent#
> </cfmail>
> 
> Does anybody have any ideas? I've tried loading the variable into 
> <cfsavecontent /> variables but it doesn't seem to work. The code that 
> is stored in the database record gets output (literally) into the 
> email but the code doesn't get executed.
> 
> Any help would be greatly appreciated. I hope I've made the problem 
> relatively clear.
> 
> Thanks,
> Tom
> 
> 
> 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306410
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to