Copy link to clipboard
Copied
Hey Everyone,
I'm new to the land of coldfsuion having come from a php background of several years. In PHP i've always had affiliations with the smarty templating engine which has a somewhat similiar style in coldfusion to cfm's if you were to call them templates.
I generally code in cfscript objects and in both cfscript and normal cfml can't find any way to return the result of an include (either with include in cfscript or cfinclude in a cfm) as a string.
We use this very often in smarty so you effectivly compile the given template and return the result as a string to display as a variable in anthher template somewhere else. I cn see that include doesn't have a return type so it's obviously in itself not the answer but if anyone knows a way of doing what i'm asking or can shed some light that would be great.
An example would be an email i want to send... something like...
<cfscript>
var mail = new Mail();
mail.setTo("blah blah");
mail.setSubject("the subject");
mail.setContents(this.getContents());
function String getContents()
{
return the result of the include here from a given cfm (e.g. include "template.cfm")
}
</cfscript>
All help appreciated!!
Cheers
Wes
Copy link to clipboard
Copied
Read up on <cfsavecontent> / savecontent:
<cfsavecontent>
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d57.html
CFScript version, "savecontent":
usage example:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSe9cbe5cf462523a0693d5dae123bcd28f6d-7ff9.html
--
Adam
Copy link to clipboard
Copied
Mate you are an absolute champion. The words I was using to search google etc found nothing leaning towards what I was after. Looks like that will do the trick.
lol and to think the example I use of mail actually has an example on the very doc page. Sorry to waste your time.
Cheers
Wes